Skip to content

Commit

Permalink
Don't use nqp::iterator for running phasers
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Dec 1, 2020
1 parent c663cc3 commit 1712f03
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/core.c/Block.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,24 @@ my class Block { # declared in BOOTSTRAP
}
}

method fire_if_phasers(Str $name --> Nil) {
nqp::if(
nqp::attrinited(self,Block,'$!phasers')
&& nqp::existskey($!phasers,$name),
nqp::stmts(
(my $iter := nqp::iterator(nqp::atkey($!phasers,$name))),
nqp::while($iter,nqp::shift($iter)(),:nohandler)
)
)
method fire_if_phasers(str $name --> Nil) {
if nqp::attrinited(self,Block,'$!phasers')
&& nqp::atkey($!phasers,$name) -> \phasers {
my int $i = -1;
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),nqp::elems(phasers)),
nqp::atpos(phasers,$i)(),
:nohandler
);
}
}

method fire_phasers(Str $name --> Nil) {
my $iter := nqp::iterator(nqp::atkey($!phasers,$name));
method fire_phasers(str $name --> Nil) {
my \phasers := nqp::atkey($!phasers,$name);
my int $i = -1;
nqp::while(
$iter,
nqp::shift($iter)(),
nqp::islt_i(($i = nqp::add_i($i,1)),nqp::elems(phasers)),
nqp::atpos(phasers,$i)(),
:nohandler
);
}
Expand Down

0 comments on commit 1712f03

Please sign in to comment.