Skip to content

Commit

Permalink
Use --/++$i instead of $i = nqp::add/sub_i($i,1)
Browse files Browse the repository at this point in the history
Any/Mu related
  • Loading branch information
lizmat committed Feb 16, 2022
1 parent 3b64a62 commit 2dfc69e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
30 changes: 15 additions & 15 deletions src/core.c/Any-iterable-methods.pm6
Expand Up @@ -947,12 +947,12 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::until(
nqp::eqaddr(($_ := $!iter.pull-one),IterationEnd)
|| $!test($_),
($!index = nqp::add_i($!index,1))
++$!index
);

nqp::eqaddr($_,IterationEnd)
?? IterationEnd
!! nqp::p6box_i($!index = nqp::add_i($!index,1))
!! nqp::p6box_i(++$!index)
}
method push-all(\target --> IterationEnd) {
my $iter := $!iter; # lexicals faster than attrs
Expand All @@ -962,7 +962,7 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::until(
nqp::eqaddr(($_ := $!iter.pull-one),IterationEnd),
nqp::stmts(
($i = nqp::add_i($i,1)),
++$i,
nqp::if(
$!test($_),
target.push(nqp::p6box_i($i))
Expand Down Expand Up @@ -999,14 +999,14 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::until(
nqp::eqaddr(($_ := $!iter.pull-one),IterationEnd)
|| $!test($_),
($!index = nqp::add_i($!index,1))
++$!index
),
nqp::if(
nqp::eqaddr($_,IterationEnd),
IterationEnd,
nqp::stmts(
($!value := $_),
nqp::p6box_i($!index = nqp::add_i($!index,1))
nqp::p6box_i(++$!index)
)
)
)
Expand All @@ -1016,7 +1016,7 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::until(
nqp::eqaddr(($_ := $!iter.pull-one),IterationEnd),
nqp::stmts(
$!index = nqp::add_i($!index,1);
++$!index,
nqp::if(
$!test($_),
nqp::stmts( # doesn't sink
Expand Down Expand Up @@ -1046,12 +1046,12 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::until(
nqp::eqaddr(($_ := $!iter.pull-one),IterationEnd)
|| $!test($_),
($!index = nqp::add_i($!index,1))
++$!index
);

nqp::eqaddr($_,IterationEnd)
?? IterationEnd
!! Pair.new(($!index = nqp::add_i($!index,1)),$_)
!! Pair.new(++$!index,$_)
}
method push-all(\target --> IterationEnd) {
my $iter := $!iter; # lexicals are faster than attrs
Expand All @@ -1061,7 +1061,7 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::until(
nqp::eqaddr(($_ := $iter.pull-one),IterationEnd),
nqp::stmts(
($i = nqp::add_i($i,1)),
++$i,
nqp::if(
$test($_),
target.push(Pair.new($i,$_))
Expand Down Expand Up @@ -1425,7 +1425,7 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::until(
(nqp::eqaddr(($_ := $iter.pull-one),IterationEnd)
|| $test($_)),
($index = nqp::add_i($index,1))
++$index
);

nqp::eqaddr($_,IterationEnd)
Expand All @@ -1439,7 +1439,7 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::stmts(
(my int $index = $elems),
nqp::while(
nqp::isge_i(($index = nqp::sub_i($index,1)),0),
nqp::isge_i(--$index,0),
nqp::if(
$test(self.AT-POS($index)),
return self!first-result(
Expand Down Expand Up @@ -1467,7 +1467,7 @@ Consider using a block if any of these are necessary for your mapping code."
),
0
),
($index = nqp::add_i($index,1))
++$index
);

nqp::eqaddr($_,IterationEnd)
Expand All @@ -1481,7 +1481,7 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::stmts(
(my int $index = $elems),
nqp::while(
nqp::isge_i(($index = nqp::sub_i($index,1)),0),
nqp::isge_i(--$index,0),
nqp::if(
nqp::isge_i(
nqp::getattr_i(
Expand Down Expand Up @@ -1509,7 +1509,7 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::until(
(nqp::eqaddr(($_ := $iter.pull-one),IterationEnd)
|| $test.ACCEPTS($_)),
($index = nqp::add_i($index,1))
++$index
);

nqp::eqaddr($_,IterationEnd)
Expand All @@ -1523,7 +1523,7 @@ Consider using a block if any of these are necessary for your mapping code."
nqp::stmts(
(my int $index = $elems),
nqp::while(
nqp::isge_i(($index = nqp::sub_i($index,1)),0),
nqp::isge_i(--$index,0),
nqp::if(
$test.ACCEPTS(self.AT-POS($index)),
return self!first-result(
Expand Down
8 changes: 4 additions & 4 deletions src/core.c/Mu.pm6
Expand Up @@ -143,7 +143,7 @@ my class Mu { # declared in BOOTSTRAP
my int $i = -1;

nqp::while(
nqp::islt_i($i = nqp::add_i($i,1),$count),
nqp::islt_i(++$i,$count),

nqp::if(
nqp::istype((my $task := nqp::atpos($bp,$i)),Callable),
Expand Down Expand Up @@ -466,7 +466,7 @@ my class Mu { # declared in BOOTSTRAP
my int $i = -1;

nqp::while(
nqp::islt_i($i = nqp::add_i($i,1),$count),
nqp::islt_i(++$i,$count),

nqp::if(
nqp::istype((my $task := nqp::atpos($bp,$i)),Callable),
Expand Down Expand Up @@ -649,15 +649,15 @@ my class Mu { # declared in BOOTSTRAP
nqp::atpos($task,2)
),
nqp::while( # 1000's flock together
nqp::islt_i(($i = nqp::add_i($i,1)),$count)
nqp::islt_i(++$i,$count)
&& nqp::islist($task := nqp::atpos($bp,$i))
&& nqp::iseq_i(nqp::atpos($task,0),1000),
nqp::getattr(self,
nqp::atpos($task,1),
nqp::atpos($task,2)
)
),
($i = nqp::sub_i($i,1))
--$i,
),

nqp::if(
Expand Down

0 comments on commit 2dfc69e

Please sign in to comment.