]> gitweb.factorcode.org Git - factor.git/commitdiff
sorting.extras: faster map-sort.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 24 Jul 2013 17:24:13 +0000 (10:24 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 24 Jul 2013 17:24:47 +0000 (10:24 -0700)
extra/sorting/extras/extras.factor

index a686b8d9fb74f2febcee0fc464c65e0b3ac786d5..988c73e145d89b15b052a656a63c22d9b3c741e5 100644 (file)
@@ -1,4 +1,5 @@
-USING: assocs kernel sequences sequences.private sorting ;
+USING: arrays assocs kernel kernel.private sequences
+sequences.private sorting ;
 IN: sorting.extras
 
 : argsort ( seq quot: ( obj1 obj2 -- <=> ) -- sortedseq )
@@ -7,5 +8,6 @@ IN: sorting.extras
     sort [ second-unsafe ] map! ; inline
 
 : map-sort ( ... seq quot: ( ... elt -- ... key ) -- ... sortedseq )
-    [ map ] curry keep zip [ first-unsafe ] sort-with
-    [ second-unsafe ] map ; inline
+    [ map ] curry keep zip
+    [ { array } declare first-unsafe ] sort-with
+    [ { array } declare second-unsafe ] map ; inline