]> gitweb.factorcode.org Git - factor.git/commitdiff
hash-sets: initialize hashtable capacity to length of sequence.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 3 Sep 2011 21:46:26 +0000 (14:46 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 3 Sep 2011 21:46:26 +0000 (14:46 -0700)
core/hash-sets/hash-sets.factor

index 028c324f6a8164669df4f53dfa7a8de54fb76207..6a03bd02d9757e9a50ab33bb503507a1e38640b9 100644 (file)
@@ -9,7 +9,9 @@ IN: hash-sets
 TUPLE: hash-set { table hashtable read-only } ;
 
 : <hash-set> ( members -- hash-set )
-    H{ } clone [ [ dupd set-at ] curry each ] keep hash-set boa ;
+    dup length <hashtable> [
+        [ dupd set-at ] curry each
+    ] keep hash-set boa ;
 
 INSTANCE: hash-set set
 M: hash-set in? table>> key? ; inline