Skip to content

Commit

Permalink
Remove unneeded boxing from count-onlys
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Apr 30, 2020
1 parent 063bfa0 commit fcda03b
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions src/core.c/Rakudo/Iterator.pm6
Expand Up @@ -53,11 +53,7 @@ class Rakudo::Iterator {
)
}
method count-only(--> Int:D) {
nqp::p6box_i(
nqp::elems($!blob)
- $!i
- nqp::islt_i($!i,nqp::elems($!blob))
)
nqp::elems($!blob) - $!i - nqp::islt_i($!i,nqp::elems($!blob))
}
method sink-all(--> IterationEnd) { $!i = nqp::elems($!blob) }
}
Expand Down Expand Up @@ -779,7 +775,7 @@ class Rakudo::Iterator {
target.push(nqp::chr($i)) while ($i = $i + 1) <= $n;
$!i = $i;
}
method count-only(--> Int:D) { nqp::p6box_i($!n - $!i) }
method count-only(--> Int:D) { $!n - $!i }
method sink-all(--> IterationEnd) { $!i = $!n }
}
method CharFromTo(\min,\max,\excludes-min,\excludes-max) {
Expand Down Expand Up @@ -2014,9 +2010,7 @@ class Rakudo::Iterator {
)
}
method is-lazy(--> Bool:D) { $!is-lazy }
method count-only(--> Int:D) {
nqp::p6box_i($!last - $!i + nqp::isgt_i($!i,$!last))
}
method count-only(--> Int:D) { $!last - $!i + nqp::isgt_i($!i,$!last) }
method sink-all(--> IterationEnd) { $!i = $!last }
}
method IntRange(\from,\to) { IntRange.new(from,to) }
Expand Down Expand Up @@ -2573,9 +2567,6 @@ class Rakudo::Iterator {
method count-only() {
nqp::not_i(nqp::eqaddr($!value,IterationEnd))
}
method bool-only() {
nqp::hllbool(nqp::not_i(nqp::eqaddr($!value,IterationEnd)))
}
}
method OneValue(Mu \value) { OneValue.new(value) }

Expand Down Expand Up @@ -2737,9 +2728,7 @@ class Rakudo::Iterator {
IterationEnd
)
}
method count-only(--> Int:D) {
nqp::p6box_i(nqp::isgt_i($!todo,0) && $!todo)
}
method count-only(--> Int:D) { nqp::isgt_i($!todo,0) && $!todo }
}
method Permutations($n, int $b) {
nqp::if(
Expand Down Expand Up @@ -2844,11 +2833,7 @@ class Rakudo::Iterator {
)
}
method count-only(--> Int:D) {
nqp::p6box_i(
nqp::elems($!reified)
- $!i
- nqp::islt_i($!i,nqp::elems($!reified))
)
nqp::elems($!reified) - $!i - nqp::islt_i($!i,nqp::elems($!reified))
}
method sink-all(--> IterationEnd) { $!i = nqp::elems($!reified) }
}
Expand Down Expand Up @@ -2934,11 +2919,7 @@ class Rakudo::Iterator {
)
}
method count-only(--> Int:D) {
nqp::p6box_i(
nqp::elems($!reified)
- $!i
- nqp::islt_i($!i,nqp::elems($!reified))
)
nqp::elems($!reified) - $!i - nqp::islt_i($!i,nqp::elems($!reified))
}
method sink-all(--> IterationEnd) { $!i = nqp::elems($!reified) }
}
Expand Down

0 comments on commit fcda03b

Please sign in to comment.