Skip to content

Commit

Permalink
Make Seq.InfiniteLoopIter about 6% faster
Browse files Browse the repository at this point in the history
Unfortunately, this iterator only gets called directly from roast,
but there does not appear to be a way to actually run this code in
any other way.  One would expect "do loop { ... }" to do this, but
that takes the WhileLoopIter variant.  Something with codegen in
Actions.nqp around line 128.
  • Loading branch information
lizmat committed Jan 28, 2017
1 parent 9d0a6c0 commit 00e60d9
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions src/core/Seq.pm
Original file line number Diff line number Diff line change
Expand Up @@ -209,40 +209,40 @@ my class Seq is Cool does Iterable does PositionalBindFailover {
has &!body;

method new(&body) {
my \iter = nqp::create(self);
nqp::bindattr(iter, self, '&!body', &body);
iter
nqp::p6bindattrinvres(nqp::create(self),self,'&!body',&body)
}

method pull-one() {
my int $redo = 1;
my $result;
if $!slipping && !(($result := self.slip-one()) =:= IterationEnd) {
$result
}
else {
nqp::while(
$redo,
nqp::stmts(
$redo = 0,
nqp::handle(
nqp::stmts(
($result := &!body()),
nqp::if(
nqp::istype($result, Slip),
nqp::stmts(
($result := self.start-slip($result)),
nqp::if(
nqp::eqaddr($result, IterationEnd),
($redo = 1)
))
)),
'NEXT', ($redo = 1),
'REDO', ($redo = 1),
'LAST', ($result := IterationEnd))),
:nohandler);
my int $stopped;
nqp::if(
$!slipping && nqp::not_i(
nqp::eqaddr(($result := self.slip-one),IterationEnd)
),
$result,
nqp::stmts(
nqp::until(
$stopped,
nqp::stmts(
($stopped = 1),
nqp::handle(
nqp::if(
nqp::istype(($result := &!body()),Slip),
($stopped = nqp::eqaddr(
($result := self.start-slip($result)),
IterationEnd
))
),
'NEXT', ($stopped = 0),
'REDO', ($stopped = 0),
'LAST', ($result := IterationEnd)
)
),
:nohandler
),
$result
}
)
)
}

method is-lazy() { True }
Expand Down

0 comments on commit 00e60d9

Please sign in to comment.