]> gitweb.factorcode.org Git - factor.git/commitdiff
hashtables.wrapped: faster >alist, keys, values.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 7 Apr 2013 19:45:38 +0000 (12:45 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 7 Apr 2013 19:45:38 +0000 (12:45 -0700)
basis/hashtables/wrapped/wrapped.factor

index d2ed473ac13249f444bf97edfaea14dd2534319d..5e35c9c5131b94e49eb80767f70fe42e6a7751c0 100644 (file)
@@ -3,7 +3,7 @@
 
 USING: accessors arrays assocs hashtables kernel sequences
 vocabs.loader ;
-
+FROM: sequences => change-nth ;
 IN: hashtables.wrapped
 
 TUPLE: wrapped-key
@@ -37,7 +37,15 @@ M: wrapped-hashtable set-at
     wrapper@ set-at ; inline
 
 M: wrapped-hashtable >alist
-    underlying>> >alist [ [ first underlying>> ] [ second ] bi 2array ] map ;
+    underlying>> >alist [
+        [ 0 swap [ underlying>> ] change-nth ] each
+    ] keep ;
+
+M: wrapped-hashtable keys
+    underlying>> keys [ underlying>> ] map! ;
+
+M: wrapped-hashtable values
+    underlying>> values ;
 
 M: wrapped-hashtable equal?
     over wrapped-hashtable? [ [ underlying>> ] same? ] [ 2drop f ] if ;