]> gitweb.factorcode.org Git - factor.git/commitdiff
hashtables: faster keys and values on hashtables.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 7 Apr 2013 04:20:07 +0000 (21:20 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 7 Apr 2013 04:20:07 +0000 (21:20 -0700)
core/hashtables/hashtables.factor

index 5a94cccbefd70d995e4c505255c70be222eafdf7..420d525e59ff9a3005df23ffd57ee1a43e92a7fa 100644 (file)
@@ -162,6 +162,16 @@ M: hashtable >alist
         [ [ 2array ] dip push-unsafe ] curry each-pair
     ] keep { } like ;
 
+M: hashtable keys
+    [ array>> ] [ assoc-size <vector> ] bi [
+        [ nip push-unsafe ] curry each-pair
+    ] keep { } like ;
+
+M: hashtable values
+    [ array>> ] [ assoc-size <vector> ] bi [
+        [ [ drop ] 2dip push-unsafe ] curry each-pair
+    ] keep { } like ;
+
 M: hashtable clone
     (clone) [ clone ] change-array ; inline