]> gitweb.factorcode.org Git - factor.git/commitdiff
random: minor speedup (random-bits).
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Feb 2013 23:26:56 +0000 (15:26 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Feb 2013 23:26:56 +0000 (15:26 -0800)
basis/random/random.factor

index bf0c8c019fbe53a2708e0dc82ae4f1558dbcf0e7..477109ec6bf1897e556ce1551d384d26e0592df8 100644 (file)
@@ -53,7 +53,7 @@ TYPED: random-bytes ( n: fixnum -- byte-array: byte-array )
 :: (random-bits) ( n bits obj -- n' )
     obj random-32* 32 bits 32 - [ dup 0 > ] [
         [ 32 shift obj random-32* + ] [ 32 + ] [ 32 - ] tri*
-    ] while drop [ n * ] [ 2^ /i ] bi* ; inline
+    ] while drop [ n * ] [ neg shift ] bi* ; inline
 
 : (random-integer) ( n obj -- n' )
     [ dup #bits ] dip (random-bits) ;