From 501231ee423ebc8ce6debea290a9ec7fd4de55a4 Mon Sep 17 00:00:00 2001 From: Timo Paulssen Date: Sat, 29 Dec 2018 02:23:26 +0100 Subject: [PATCH] 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. --- src/core/Iterator.pm6 | 10 +++++----- src/core/List.pm6 | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/Iterator.pm6 b/src/core/Iterator.pm6 index 0417faaffa5..90da2520532 100644 --- a/src/core/Iterator.pm6 +++ b/src/core/Iterator.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) ) } diff --git a/src/core/List.pm6 b/src/core/List.pm6 index 1499b287322..50996ca0974 100644 --- a/src/core/List.pm6 +++ b/src/core/List.pm6 @@ -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 )