Skip to content

Commit

Permalink
Micro optimize List.roll($n)
Browse files Browse the repository at this point in the history
Lexicals are faster than private attributes.
  • Loading branch information
MasterDuke17 committed Apr 2, 2018
1 parent 111f67a commit c71ff66
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/List.pm6
Expand Up @@ -1077,11 +1077,15 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
}
}
method push-all($target --> IterationEnd) {
nqp::while(
$!todo,
nqp::stmts(
($target.push(nqp::atpos($!list,$!elems.rand.floor))),
($!todo = $!todo - 1)
nqp::stmts(
(my int $todo = $!todo),
(my int $elems = $!elems),
nqp::while(
$todo,
nqp::stmts(
($target.push(nqp::atpos($!list,$elems.rand.floor))),
($todo = $todo - 1)
)
)
)
}
Expand Down

0 comments on commit c71ff66

Please sign in to comment.