Skip to content

Commit

Permalink
Replace HyperToIterator.push-all by push-exactly
Browse files Browse the repository at this point in the history
The difference between the two is just one int condition and one int assignment
per HyperWorkBatch, which is neatly shown in the diff of this commit.
The extra work, at least currently, completely gets lost in the noise.

Also fix superfluous check and return value in skip-at-least: we only exit the
loop through -return- anyway.
  • Loading branch information
lizmat committed Mar 20, 2018
1 parent ae0cbc3 commit ec5416a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/core/Rakudo/Internals/HyperToIterator.pm6
Expand Up @@ -71,7 +71,7 @@ my class Rakudo::Internals::HyperToIterator does Rakudo::Internals::HyperJoiner

method skip-at-least(int $skipping) {
my int $toskip = $skipping;
while $toskip {
loop {
if nqp::isge_i(nqp::elems($!current-items),$toskip) {
nqp::splice($!current-items,EMPTY_BUFFER,0,$toskip);
return 1;
Expand All @@ -90,12 +90,21 @@ my class Rakudo::Internals::HyperToIterator does Rakudo::Internals::HyperJoiner
}
}
}
0
}

method push-all($target) {
method push-exactly($target, int $pushing) {
my int $topush = $pushing;
my int $pushed = 0;
loop {
if nqp::isge_i(nqp::elems($!current-items),$topush) {
$target.append(
nqp::clone(nqp::setelems($!current-items,$topush))
);
nqp::splice($!current-items,EMPTY_BUFFER,0,$topush);
return $pushed + $topush;
}
$target.append($!current-items);
$pushed = $pushed + nqp::elems($!current-items);
$!current-items := $!batches.receive.items;
self.batch-used();

Expand Down

0 comments on commit ec5416a

Please sign in to comment.