From f835bb01f4ac937f70db3e03fa516c3a5aa5fccb Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 23 Oct 2012 19:30:20 -0700 Subject: [PATCH] io.random: bit faster using set-nth-unsafe. --- extra/io/random/random.factor | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extra/io/random/random.factor b/extra/io/random/random.factor index 0c0f28d29f..47abdec2ed 100644 --- a/extra/io/random/random.factor +++ b/extra/io/random/random.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license USING: combinators fry io kernel locals math math.order random -sequences ; +sequences sequences.private ; IN: io.random @@ -19,10 +19,10 @@ PRIVATE> :: random-lines ( n -- lines ) V{ } clone :> accum [| line line# | - line# n <=> { - { +lt+ [ line accum push ] } - { +eq+ [ line accum [ push ] [ randomize drop ] bi ] } - { +gt+ [ line# random :> r - r n < [ line r accum set-nth ] when ] } - } case + line# n <= [ + line accum push + ] [ + line# random :> r + r n < [ line r accum set-nth-unsafe ] when + ] if ] each-numbered-line accum ;