Skip to content
Permalink
Browse files

Eliminate A Few Scalar Allocs For Push-All

I could not measure a performance benefit
in the benchmark I had, but the bytecode
got a bit simpler and total allocation count
decreased a little.
  • Loading branch information...
timo committed Dec 29, 2018
1 parent 2ce7956 commit 501231ee423ebc8ce6debea290a9ec7fd4de55a4
Showing with 8 additions and 8 deletions.
  1. +5 −5 src/core/Iterator.pm6
  2. +3 −3 src/core/List.pm6
@@ -52,10 +52,10 @@ my role Iterator {

# Has the iterator produce all of its values into the target. Typically
# called in .STORE if the iterator is non-lazy. Returns IterationEnd.
method push-all($target --> IterationEnd) {
method push-all(\target --> IterationEnd) {
nqp::until( # we may not .sink $pulled here, since it can be a Seq
nqp::eqaddr((my $pulled := self.pull-one),IterationEnd),
$target.push($pulled)
nqp::eqaddr((my \pulled := self.pull-one),IterationEnd),
target.push(pulled)
)
}

@@ -66,10 +66,10 @@ my role Iterator {
# calls push-all. If all values the iterator can produce are pushed, then
# IterationEnd should be returned. Otherwise, return something else (Mu
# will do fine).
method push-until-lazy($target) {
method push-until-lazy(\target) {
nqp::unless(
self.is-lazy,
self.push-all($target)
self.push-all(target)
)
}

@@ -630,14 +630,14 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
IterationEnd
}

method push-until-lazy($target) {
method push-until-lazy(\target) {
nqp::if(
nqp::isconcrete($!todo),
nqp::stmts( # something to reify still
(my int $elems = $!todo.reify-until-lazy),
nqp::while( # doesn't sink
nqp::islt_i($!i = nqp::add_i($!i,1),$elems),
$target.push(nqp::atpos($!reified,$!i))
target.push(nqp::atpos($!reified,$!i))
),
nqp::if(
$!todo.fully-reified,
@@ -652,7 +652,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
($elems = nqp::elems($!reified)),
nqp::while( # doesn't sink
nqp::islt_i($!i = nqp::add_i($!i,1),$elems),
$target.push(nqp::atpos($!reified,$!i))
target.push(nqp::atpos($!reified,$!i))
),
IterationEnd
)

0 comments on commit 501231e

Please sign in to comment.
You can’t perform that action at this time.