Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
avoid last in loop in gather that blows up jvm
  • Loading branch information
TimToady committed Apr 10, 2015
1 parent 5a3f388 commit 0354bb6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/core/operators.pm
Expand Up @@ -353,9 +353,9 @@ sub SEQUENCE($left, Mu $right, :$exclude_end) {
if $stop { }
elsif $code.defined {
take $_ for @$tail;

my $count = $code.count;
while 1 {

until $stop {
$tail.shift while $tail.elems > $count;
my \value = $code(|$tail);
if $end_code_arity != 0 {
Expand All @@ -364,15 +364,17 @@ sub SEQUENCE($left, Mu $right, :$exclude_end) {
$end_tail.munch($end_tail.elems - $end_code_arity) unless $end_code_arity == -Inf;
if $endpoint(|@$end_tail) {
(.take for value) unless $exclude_end;
last;
$stop = 1;
}
}
}
elsif value ~~ $endpoint {
(.take for value) unless $exclude_end;
last;
$stop = 1;
}
if value {

if $stop { }
elsif value {
$tail.push(|value);
.take for value;
}
Expand Down

0 comments on commit 0354bb6

Please sign in to comment.