Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
don't try to make a batch of size 0
  • Loading branch information
TimToady committed Aug 19, 2014
1 parent a82c407 commit 1a7f85b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/List.pm
Expand Up @@ -638,14 +638,15 @@ multi infix:<xx>(Mu \x, Whatever) {
multi infix:<xx>(Mu \x, $n is copy) {
$n = $n.Int;
if $n <= 10 {
GatherIter.new({ take x while --$n >= 0; }).list
GatherIter.new({ take x while --$n >= 0; }).flat
}
else {
my \size = floor sqrt($n);
my \batch := infix:<xx>(x, size);
GatherIter.new({
{ take batch while ($n -= size) >= 0; }
take batch[0 ..^ $n + size];
take batch while ($n -= size) >= 0;
$n += size; # make up for extra -=
take batch[0 ..^ $n] if $n;
}).flat
}
}
Expand Down

0 comments on commit 1a7f85b

Please sign in to comment.