Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
s/foo.CREATE/nqp::create(foo)/
This appears to have a positive effect on spectest duration/CPU usage,
so assume this will be noticeable elsewhere as well.  If not, please
revert  :-)
  • Loading branch information
lizmat committed Nov 15, 2015
1 parent 6bc9bba commit 8e19973
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 78 deletions.
6 changes: 3 additions & 3 deletions src/core/Any-iterable-methods.pm
Expand Up @@ -28,7 +28,7 @@ augment class Any {
has &!block;

method new(\source, &block) {
my \iter = self.CREATE;
my \iter = nqp::create(self);
nqp::bindattr(iter, self, '$!source', source);
nqp::bindattr(iter, self, '&!block', &block);
iter
Expand Down Expand Up @@ -61,7 +61,7 @@ augment class Any {
has $!label;

method new(&block, $source, $count, $label) {
my $iter := self.CREATE;
my $iter := nqp::create(self);
nqp::bindattr($iter, self, '&!block', &block);
nqp::bindattr($iter, self, '$!source', $source);
nqp::bindattr($iter, self, '$!count', $count);
Expand Down Expand Up @@ -907,7 +907,7 @@ augment class Any {
my $transform-buffer;
if $transform {
$transform-buffer := IterationBuffer.new;
my \to-map = nqp::p6bindattrinvres(List.CREATE, List, '$!reified',
my \to-map = nqp::p6bindattrinvres(nqp::create(List), List, '$!reified',
sort-buffer);
to-map.map(&by).iterator.push-all($transform-buffer);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Any.pm
Expand Up @@ -12,7 +12,7 @@ my class X::Subscript::Negative { ... }
my role Numeric { ... }

# We use a sentinel value to mark the end of an iteration.
my constant IterationEnd = Mu.CREATE;
my constant IterationEnd = nqp::create(Mu);

my class Any { # declared in BOOTSTRAP
# my class Any is Mu {
Expand Down
38 changes: 19 additions & 19 deletions src/core/Array.pm
Expand Up @@ -15,7 +15,7 @@ my class Array { # declared in BOOTSTRAP
has $!descriptor;

method new(\target, Mu \descriptor) {
my \rt = self.CREATE;
my \rt = nqp::create(self);
nqp::bindattr(rt, self, '$!target', target);
nqp::bindattr(rt, self, '$!descriptor', descriptor);
rt
Expand All @@ -31,7 +31,7 @@ my class Array { # declared in BOOTSTRAP
has $!target;

method new(\target) {
nqp::p6bindattrinvres(self.CREATE, self, '$!target', target);
nqp::p6bindattrinvres(nqp::create(self), self, '$!target', target);
}

method push(Mu \value) {
Expand All @@ -41,9 +41,9 @@ my class Array { # declared in BOOTSTRAP
}

method from-iterator(Array:U: Iterator $iter) {
my \result := self.CREATE;
my \buffer := IterationBuffer.CREATE;
my \todo := List::Reifier.CREATE;
my \result := nqp::create(self);
my \buffer := nqp::create(IterationBuffer);
my \todo := nqp::create(List::Reifier);
nqp::bindattr(result, List, '$!reified', buffer);
nqp::bindattr(result, List, '$!todo', todo);
nqp::bindattr(todo, List::Reifier, '$!reified', buffer);
Expand Down Expand Up @@ -313,7 +313,7 @@ my class Array { # declared in BOOTSTRAP
}

method !ensure-allocated() {
nqp::bindattr(self, List, '$!reified', IterationBuffer.CREATE)
nqp::bindattr(self, List, '$!reified', nqp::create(IterationBuffer))
unless nqp::getattr(self, List, '$!reified').DEFINITE;
}

Expand Down Expand Up @@ -344,15 +344,15 @@ my class Array { # declared in BOOTSTRAP
self!STORE-ONE(item)
}
method !STORE-ITERABLE(\iterable) {
my \new-storage = IterationBuffer.CREATE;
my \new-storage = nqp::create(IterationBuffer);
my \iter = iterable.iterator;
my \target = ArrayReificationTarget.new(new-storage,
nqp::decont($!descriptor));
if iter.push-until-lazy(target) =:= IterationEnd {
nqp::bindattr(self, List, '$!todo', Mu);
}
else {
my \new-todo = List::Reifier.CREATE;
my \new-todo = nqp::create(List::Reifier);
nqp::bindattr(new-todo, List::Reifier, '$!reified', new-storage);
nqp::bindattr(new-todo, List::Reifier, '$!current-iter', iter);
nqp::bindattr(new-todo, List::Reifier, '$!reification-target', target);
Expand All @@ -362,7 +362,7 @@ my class Array { # declared in BOOTSTRAP
self
}
method !STORE-ONE(Mu \item) {
my \new-storage = IterationBuffer.CREATE;
my \new-storage = nqp::create(IterationBuffer);
nqp::push(new-storage,
nqp::assign(nqp::p6scalarfromdesc($!descriptor), item));
nqp::bindattr(self, List, '$!reified', new-storage);
Expand All @@ -382,8 +382,8 @@ my class Array { # declared in BOOTSTRAP
multi method List(Array:D:) {
self!ensure-allocated;
X::Cannot::Lazy.new(:action<List>).throw if self.is-lazy;
my \retval := List.CREATE;
my \reified := IterationBuffer.CREATE;
my \retval := nqp::create(List);
my \reified := nqp::create(IterationBuffer);
nqp::bindattr(retval, List, '$!reified', reified);
my \target := ListReificationTarget.new(reified);
self.iterator.push-all(target);
Expand Down Expand Up @@ -586,7 +586,7 @@ my class Array { # declared in BOOTSTRAP
self!prepend-list(@values)
}
method !prepend-list(@values) {
my \containers := IterationBuffer.CREATE;
my \containers := nqp::create(IterationBuffer);
my \target := ArrayReificationTarget.new(containers,
nqp::decont($!descriptor));

Expand Down Expand Up @@ -795,14 +795,14 @@ my class Array { # declared in BOOTSTRAP
# The [...] term creates an Array.
proto circumfix:<[ ]>(|) { * }
multi circumfix:<[ ]>() {
my \result = Array.CREATE;
nqp::bindattr(result, List, '$!reified', IterationBuffer.CREATE);
my \result = nqp::create(Array);
nqp::bindattr(result, List, '$!reified', nqp::create(IterationBuffer));
result
}
multi circumfix:<[ ]>(Iterable:D \iterable) {
if nqp::iscont(iterable) {
my \result = Array.CREATE;
my \buffer = IterationBuffer.CREATE;
my \result = nqp::create(Array);
my \buffer = nqp::create(IterationBuffer);
buffer.push(iterable);
nqp::bindattr(result, List, '$!reified', buffer);
result
Expand All @@ -813,15 +813,15 @@ multi circumfix:<[ ]>(Iterable:D \iterable) {
}
multi circumfix:<[ ]>(|) {
my \in = nqp::p6argvmarray();
my \result = Array.CREATE;
my \reified = IterationBuffer.CREATE;
my \result = nqp::create(Array);
my \reified = nqp::create(IterationBuffer);
nqp::bindattr(result, List, '$!reified', reified);
while nqp::elems(in) {
if nqp::istype(nqp::atpos(in, 0), Slip) {
# We saw a Slip, which may expand to something lazy. Put all that
# remains in the future, and let normal reification take care of
# it.
my \todo := List::Reifier.CREATE;
my \todo := nqp::create(List::Reifier);
nqp::bindattr(result, List, '$!todo', todo);
nqp::bindattr(todo, List::Reifier, '$!reified', reified);
nqp::bindattr(todo, List::Reifier, '$!future', in);
Expand Down
6 changes: 3 additions & 3 deletions src/core/Hash.pm
Expand Up @@ -432,7 +432,7 @@ my class Hash { # declared in BOOTSTRAP
has $!hash-iter;

method new(\hash, $class) {
my \iter = self.CREATE;
my \iter = nqp::create(self);
nqp::bindattr(iter, self, '$!hash-iter',
nqp::iterator(nqp::getattr(hash, $class, '$!keys')));
iter
Expand All @@ -456,7 +456,7 @@ my class Hash { # declared in BOOTSTRAP
has $!current-value;

method new(\hash, $class, $storage) {
my \iter = self.CREATE;
my \iter = nqp::create(self);
nqp::bindattr(iter, self, '$!hash-iter',
nqp::iterator(nqp::getattr(hash, $class, '$!keys')));
nqp::bindattr(iter, self, '$!storage', nqp::decont($storage));
Expand Down Expand Up @@ -489,7 +489,7 @@ my class Hash { # declared in BOOTSTRAP
has $!storage;

method new(\hash, $class, $storage) {
my \iter = self.CREATE;
my \iter = nqp::create(self);
nqp::bindattr(iter, self, '$!hash-iter',
nqp::iterator(nqp::getattr(hash, $class, '$!keys')));
nqp::bindattr(iter, self, '$!storage', nqp::decont($storage));
Expand Down
8 changes: 4 additions & 4 deletions src/core/HyperSeq.pm
Expand Up @@ -11,7 +11,7 @@ my class HyperSeq does Iterable does HyperIterable does PositionalBindFailover {
# The only valid way to create a HyperSeq directly is by giving it the
# hyper-iterator it will expose and maybe memoize.
method new(HyperIterator:D $hyper-iter) {
my \hseq := self.CREATE;
my \hseq := nqp::create(self);
nqp::bindattr(hseq, HyperSeq, '$!hyper-iter', nqp::decont($hyper-iter));
hseq
}
Expand Down Expand Up @@ -52,12 +52,12 @@ my class HyperSeq does Iterable does HyperIterable does PositionalBindFailover {
has int $!sequence-number;

method new(\hyper-iterator) {
my \iter = self.CREATE;
my \iter = nqp::create(self);
my \lock = Lock.new;
nqp::bindattr(iter, self, '$!hyper-iterator', hyper-iterator);
nqp::bindattr(iter, self, '$!configuration', hyper-iterator.configuration);
nqp::bindattr(iter, self, '$!work-available', IterationBuffer.CREATE);
nqp::bindattr(iter, self, '$!work-completed', IterationBuffer.CREATE);
nqp::bindattr(iter, self, '$!work-available', nqp::create(IterationBuffer));
nqp::bindattr(iter, self, '$!work-completed', nqp::create(IterationBuffer));
nqp::bindattr(iter, self, '$!lock', lock);
nqp::bindattr(iter, self, '$!cond-have-work', lock.condition);
nqp::bindattr(iter, self, '$!cond-have-result', lock.condition);
Expand Down
8 changes: 4 additions & 4 deletions src/core/HyperWorkBuffer.pm
Expand Up @@ -8,9 +8,9 @@ my class HyperWorkBuffer {
has $.output;

method new() {
my \wb = self.CREATE;
nqp::bindattr(wb, HyperWorkBuffer, '$!input', IterationBuffer.CREATE);
nqp::bindattr(wb, HyperWorkBuffer, '$!output', IterationBuffer.CREATE);
my \wb = nqp::create(self);
nqp::bindattr(wb, HyperWorkBuffer, '$!input', nqp::create(IterationBuffer));
nqp::bindattr(wb, HyperWorkBuffer, '$!output', nqp::create(IterationBuffer));
wb
}

Expand Down Expand Up @@ -39,7 +39,7 @@ my class HyperWorkBuffer {
has int $!i;

method new(\buffer) {
my \iter = self.CREATE;
my \iter = nqp::create(self);
nqp::bindattr(iter, self, '$!buffer', buffer);
iter
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IO/ArgFiles.pm
Expand Up @@ -60,7 +60,7 @@ my class IO::ArgFiles is IO::Handle {
has $!ins;

method new(\args, \ins, \limit, \next-io) {
my \iter = self.CREATE;
my \iter = nqp::create(self);
nqp::bindattr(iter, self, '$!args', args);
nqp::bindattr(iter, self, '$!ins', ins);
nqp::bindattr(iter, self, '$!next-io', next-io);
Expand Down
6 changes: 3 additions & 3 deletions src/core/Iterable.pm
Expand Up @@ -26,7 +26,7 @@ my role Iterable {
iter
}

my constant NO_RESULT_YET = Mu.CREATE;
my constant NO_RESULT_YET = nqp::create(Mu);
method pull-one() is raw {
my $result := NO_RESULT_YET;
my $got;
Expand Down Expand Up @@ -89,7 +89,7 @@ my role Iterable {
has $!iterator;

method new(\iterable) {
my \iter = self.CREATE;
my \iter = nqp::create(self);
nqp::bindattr(iter, self, '$!iterable', iterable);
iter
}
Expand Down Expand Up @@ -122,7 +122,7 @@ my role Iterable {
has $!configuration;

method new(\iter, $configuration) {
my \hyper-iter = self.CREATE;
my \hyper-iter = nqp::create(self);
nqp::bindattr(hyper-iter, self, '$!source', iter);
nqp::bindattr(hyper-iter, self, '$!configuration', $configuration);
hyper-iter
Expand Down
46 changes: 23 additions & 23 deletions src/core/List.pm
Expand Up @@ -171,9 +171,9 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
}

method from-iterator(List:U: Iterator $iter) {
my \result := self.CREATE;
my \buffer := IterationBuffer.CREATE;
my \todo := Reifier.CREATE;
my \result := nqp::create(self);
my \buffer := nqp::create(IterationBuffer);
my \todo := nqp::create(Reifier);
nqp::bindattr(result, List, '$!reified', buffer);
nqp::bindattr(result, List, '$!todo', todo);
nqp::bindattr(todo, Reifier, '$!reified', buffer);
Expand All @@ -185,9 +185,9 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP

method from-slurpy(|) {
my Mu \vm-tuple = nqp::captureposarg(nqp::usecapture(), 1);
my \result := self.CREATE;
my \buffer := IterationBuffer.CREATE;
my \todo := List::Reifier.CREATE;
my \result := nqp::create(self);
my \buffer := nqp::create(IterationBuffer);
my \todo := nqp::create(List::Reifier);
nqp::bindattr(result, List, '$!reified', buffer);
nqp::bindattr(result, List, '$!todo', todo);
nqp::bindattr(todo, List::Reifier, '$!reified', buffer);
Expand All @@ -208,9 +208,9 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
nqp::istype(self,Array) ?? consider.cache !! consider;
}
else {
my \result := self.CREATE;
my \buffer := IterationBuffer.CREATE;
my \todo := List::Reifier.CREATE;
my \result := nqp::create(self);
my \buffer := nqp::create(IterationBuffer);
my \todo := nqp::create(List::Reifier);
nqp::bindattr(result, List, '$!reified', buffer);
nqp::bindattr(result, List, '$!todo', todo);
nqp::bindattr(todo, List::Reifier, '$!reified', buffer);
Expand All @@ -228,7 +228,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP

method from-slurpy-flat(|) {
my Mu \vm-tuple = nqp::captureposarg(nqp::usecapture(), 1);
my \future = IterationBuffer.CREATE;
my \future = nqp::create(IterationBuffer);
my int $i = 0;
my int $n = nqp::elems(vm-tuple);
while $i < $n {
Expand All @@ -244,9 +244,9 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
$i = $i + 1;
}

my \result := self.CREATE;
my \buffer := IterationBuffer.CREATE;
my \todo := List::Reifier.CREATE;
my \result := nqp::create(self);
my \buffer := nqp::create(IterationBuffer);
my \todo := nqp::create(List::Reifier);
nqp::bindattr(result, List, '$!reified', buffer);
nqp::bindattr(result, List, '$!todo', todo);
nqp::bindattr(todo, List::Reifier, '$!reified', buffer);
Expand All @@ -257,8 +257,8 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
}

method new(**@things) {
my \list = self.CREATE;
my \iterbuffer = IterationBuffer.CREATE;
my \list = nqp::create(self);
my \iterbuffer = nqp::create(IterationBuffer);
nqp::bindattr(list, List, '$!reified', iterbuffer);
for @things {
my $no-sink := iterbuffer.push($_);
Expand All @@ -267,7 +267,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
}

method !ensure-allocated() {
$!reified := IterationBuffer.CREATE unless $!reified.DEFINITE;
$!reified := nqp::create(IterationBuffer) unless $!reified.DEFINITE;
}

multi method Bool(List:D:) {
Expand Down Expand Up @@ -622,7 +622,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
else {
# We're fully reified - and so immutable inside and out! Just make
# a Slip that shares our reified buffer.
my \result := Slip.CREATE;
my \result := nqp::create(Slip);
nqp::bindattr(result, List, '$!reified', $!reified);
result
}
Expand All @@ -645,7 +645,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
my $cap := nqp::create(Capture);
nqp::bindattr($cap, Capture, '$!list', $!reified);

my \positional := IterationBuffer.CREATE;
my \positional := nqp::create(IterationBuffer);
my Mu $hash := nqp::hash();
my int $c = nqp::elems($!reified);
my int $i = 0;
Expand Down Expand Up @@ -932,20 +932,20 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
# The , operator produces a List.
proto sub infix:<,>(|) is pure {*}
multi sub infix:<,>() {
my \result = List.CREATE;
nqp::bindattr(result, List, '$!reified', BEGIN IterationBuffer.CREATE);
my \result = nqp::create(List);
nqp::bindattr(result, List, '$!reified', BEGIN nqp::create(IterationBuffer));
result
}
multi sub infix:<,>(|) {
my \result = List.CREATE;
my \result = nqp::create(List);
my \in = nqp::p6argvmarray();
my \reified = IterationBuffer.CREATE;
my \reified = nqp::create(IterationBuffer);
nqp::bindattr(result, List, '$!reified', reified);
while nqp::elems(in) {
if nqp::istype(nqp::atpos(in, 0), Slip) {
# We saw a Slip, so we'll lazily deal with the rest of the things
# (as the Slip may expand to something lazy).
my \todo := List::Reifier.CREATE;
my \todo := nqp::create(List::Reifier);
nqp::bindattr(result, List, '$!todo', todo);
nqp::bindattr(todo, List::Reifier, '$!reified', reified);
nqp::bindattr(todo, List::Reifier, '$!future', in);
Expand Down

0 comments on commit 8e19973

Please sign in to comment.