Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't use no bloody intermediate
The win is in the noise range (about %1), but it simplifies the code, and that
is a good thing, no?
  • Loading branch information
lizmat committed Apr 24, 2015
1 parent 224db5e commit 1905fc1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/core/List.pm
Expand Up @@ -197,15 +197,13 @@ my class List does Positional { # declared in BOOTSTRAP

my Mu $rpa := nqp::clone($!items);
my int $i;
my Mu $v;
gather while $n {
$i = nqp::rand_I(nqp::decont($elems), Int);
$elems = $elems - 1;
$n = $n - 1;
$v := nqp::atpos($rpa,$i);
take-rw nqp::atpos($rpa,$i);
# replace selected element with last unpicked one
nqp::bindpos($rpa,$i,nqp::atpos($rpa,nqp::unbox_i($elems)));
take-rw $v;
}
}

Expand Down

0 comments on commit 1905fc1

Please sign in to comment.