]> gitweb.factorcode.org Git - factor.git/commitdiff
random: speedup randomize.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Feb 2013 22:51:29 +0000 (14:51 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Feb 2013 22:51:29 +0000 (14:51 -0800)
basis/random/random.factor

index 9eb914d3688bc870fea71af132f020ca38c045fe..bf0c8c019fbe53a2708e0dc82ae4f1558dbcf0e7 100644 (file)
@@ -94,8 +94,10 @@ M: hash-set random table>> random first ;
 
 : randomize-n-last ( seq n -- seq )
     [ dup length dup ] dip - 1 max '[ dup _ > ]
-    [ [ random ] [ 1 - ] bi [ pick exchange-unsafe ] keep ]
-    while drop ;
+    random-generator get '[
+        [ _ (random-integer) ] [ 1 - ] bi
+        [ pick exchange-unsafe ] keep
+    ] while drop ;
 
 : randomize ( seq -- randomized )
     dup length randomize-n-last ;