Skip to content

Commit

Permalink
s/IterationBuffer.new/nqp::create(IterationBuffer)/
Browse files Browse the repository at this point in the history
IterationBuffers are a low level thing.  There is no need to go through
the whole Mu.new code path to create an IterationBuffer.
  • Loading branch information
lizmat committed Oct 9, 2018
1 parent 8c10da6 commit 84311b7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/core/Any-iterable-methods.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,8 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
multi method sort() {
nqp::if(
nqp::eqaddr(
self.iterator.push-until-lazy(my \buf := IterationBuffer.new),
self.iterator.push-until-lazy(
my \buf := nqp::create(IterationBuffer)),
IterationEnd
),
Seq.new(
Expand All @@ -1466,7 +1467,8 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
nqp::stmts(
nqp::unless(
nqp::eqaddr(
self.iterator.push-until-lazy(my \buf := IterationBuffer.new),
self.iterator.push-until-lazy(
my \buf := nqp::create(IterationBuffer)),
IterationEnd
),
X::Cannot::Lazy.new(:action<sort>).throw
Expand Down
2 changes: 1 addition & 1 deletion src/core/Array.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ my class Array { # declared in BOOTSTRAP
method !splice-offset-size-new(int $offset,int $size,@new) {
nqp::if(
nqp::eqaddr(@new.iterator.push-until-lazy(
(my $new := IterationBuffer.new)),IterationEnd),
(my $new := nqp::create(IterationBuffer))),IterationEnd),
nqp::if( # reified all values to splice in
(nqp::isnull($!descriptor) || nqp::eqaddr(self.of,Mu)),
nqp::stmts( # no typecheck needed
Expand Down
2 changes: 1 addition & 1 deletion src/core/Rakudo/Internals.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ my class Rakudo::Internals {

my \result := CoreMap.new(op, iterable.iterator, $deep);
my \type := nqp::istype(obj, List) ?? obj.WHAT !! List; # keep subtypes of List
my \buffer := IterationBuffer.new;
my \buffer := nqp::create(IterationBuffer);
result.push-all(buffer);
my \retval := type.new;
nqp::bindattr(retval, List, '$!reified', buffer);
Expand Down
2 changes: 1 addition & 1 deletion src/core/Rakudo/Iterator.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ class Rakudo::Iterator {
has int $!i;
method !SET-SELF(\source) {
$!source := source;
$!buffer := IterationBuffer.new;
$!buffer := nqp::create(IterationBuffer);
self
}
method new(\source) { nqp::create(self)!SET-SELF(source) }
Expand Down
4 changes: 2 additions & 2 deletions src/core/hash_slice.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ sub MD-HASH-SLICE-ONE-POSITION(\SELF, \indices, \idx, int $dim, \target) {
}

multi sub postcircumfix:<{; }>(\SELF, @indices) {
my \target = IterationBuffer.new;
my \target = nqp::create(IterationBuffer);
MD-HASH-SLICE-ONE-POSITION(SELF, @indices, @indices.AT-POS(0), 0, target);
nqp::p6bindattrinvres(nqp::create(List), List, '$!reified', target)
target.List
}

multi sub postcircumfix:<{; }>(\SELF, @indices, :$exists!) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/metaops.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ multi sub HYPER(&operator, Iterable:D \left, Iterable:D \right, :$dwim-left, :$d
my \lefti := Rakudo::Iterator.DWIM(left-iterator);
my \righti := Rakudo::Iterator.DWIM(right-iterator);

my \result := IterationBuffer.new;
my \result := nqp::create(IterationBuffer);
loop {
my \leftv := lefti.pull-one;
my \rightv := righti.pull-one;
Expand Down
4 changes: 2 additions & 2 deletions src/core/multidim_slice.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ sub MD-ARRAY-SLICE-ONE-POSITION(\SELF, \indices, \idx, int $dim, \target) is raw
}
}
sub MD-ARRAY-SLICE(\SELF, @indices) is raw {
my \target = IterationBuffer.new;
my \target = nqp::create(IterationBuffer);
MD-ARRAY-SLICE-ONE-POSITION(SELF, @indices, @indices.AT-POS(0), 0, target);
nqp::p6bindattrinvres(nqp::create(List), List, '$!reified', target)
target.List
}

multi sub postcircumfix:<[; ]>(\SELF, @indices) is raw {
Expand Down

0 comments on commit 84311b7

Please sign in to comment.