]> gitweb.factorcode.org Git - factor.git/commitdiff
cuckoo-filters: less duplication in cuckoo-insert.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 9 Aug 2016 02:39:24 +0000 (19:39 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 9 Aug 2016 02:39:24 +0000 (19:39 -0700)
extra/cuckoo-filters/cuckoo-filters.factor

index ca3d383ccc494f87399e4b7d35396c33621ddeb7..87dc1d189865ca2340c03f6b5214154c2e016271 100644 (file)
@@ -62,7 +62,7 @@ TUPLE: cuckoo-filter buckets checksum size ;
         [ fp i1 n mod buckets nth bucket-insert ]
         [ fp i2 n mod buckets nth bucket-insert ]
     } 0|| [
-        cuckoo-filter [ 1 + ] change-size drop t
+        t
     ] [
         2 random zero? i1 i2 ? :> i!
         max-cuckoo-count [
@@ -71,9 +71,9 @@ TUPLE: cuckoo-filter buckets checksum size ;
             fp i alt-index i!
 
             fp i n mod buckets nth bucket-insert
-            dup [ cuckoo-filter [ 1 + ] change-size drop ] when
         ] find-integer >boolean
-    ] if ;
+    ] if
+    dup [ cuckoo-filter [ 1 + ] change-size drop ] when ;
 
 :: cuckoo-lookup ( bytes cuckoo-filter -- ? )
     bytes cuckoo-filter hash-indices :> ( fp i1 i2 )