Skip to content

Commit

Permalink
Merge pull request #1682 from MasterDuke17/micro_optimize_Lists_roll
Browse files Browse the repository at this point in the history
Micro-optimize List.roll($n)
  • Loading branch information
AlexDaniel committed Apr 2, 2018
2 parents 111f67a + c71ff66 commit f1b9c7d
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 f1b9c7d

Please sign in to comment.