Skip to content

Commit

Permalink
Micro-optimize native array iterator
Browse files Browse the repository at this point in the history
By not using a private method
  • Loading branch information
lizmat committed Apr 9, 2018
1 parent 28c9ae4 commit a2d8c96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/core/native_array.pm6
Expand Up @@ -57,7 +57,7 @@ my class array does Iterable {

my role strarray[::T] does Positional[T] is array_type(T) {
#- start of generated part of strarray role -----------------------------------
#- Generated on 2018-04-09T09:53:10+02:00 by tools/build/makeNATIVE_ARRAY.pl6
#- Generated on 2018-04-09T10:32:44+02:00 by tools/build/makeNATIVE_ARRAY.pl6
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE

multi method AT-POS(strarray:D: int $idx) is raw {
Expand Down Expand Up @@ -295,12 +295,12 @@ my class array does Iterable {
has int $!i;
has $!array; # Native array we're iterating

method !SET-SELF(\array) {
method SET-SELF(\array) {
$!array := nqp::decont(array);
$!i = -1;
self
}
method new(\array) { nqp::create(self)!SET-SELF(array) }
method new(\array) { nqp::create(self).SET-SELF(array) }

method pull-one() is raw {
($!i = $!i + 1) < nqp::elems($!array)
Expand Down Expand Up @@ -428,7 +428,7 @@ my class array does Iterable {

my role intarray[::T] does Positional[T] is array_type(T) {
#- start of generated part of intarray role -----------------------------------
#- Generated on 2018-04-09T09:53:10+02:00 by tools/build/makeNATIVE_ARRAY.pl6
#- Generated on 2018-04-09T10:32:44+02:00 by tools/build/makeNATIVE_ARRAY.pl6
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE

multi method AT-POS(intarray:D: int $idx) is raw {
Expand Down Expand Up @@ -666,12 +666,12 @@ my class array does Iterable {
has int $!i;
has $!array; # Native array we're iterating

method !SET-SELF(\array) {
method SET-SELF(\array) {
$!array := nqp::decont(array);
$!i = -1;
self
}
method new(\array) { nqp::create(self)!SET-SELF(array) }
method new(\array) { nqp::create(self).SET-SELF(array) }

method pull-one() is raw {
($!i = $!i + 1) < nqp::elems($!array)
Expand Down Expand Up @@ -824,7 +824,7 @@ my class array does Iterable {

my role numarray[::T] does Positional[T] is array_type(T) {
#- start of generated part of numarray role -----------------------------------
#- Generated on 2018-04-09T09:53:10+02:00 by tools/build/makeNATIVE_ARRAY.pl6
#- Generated on 2018-04-09T10:32:44+02:00 by tools/build/makeNATIVE_ARRAY.pl6
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE

multi method AT-POS(numarray:D: int $idx) is raw {
Expand Down Expand Up @@ -1062,12 +1062,12 @@ my class array does Iterable {
has int $!i;
has $!array; # Native array we're iterating

method !SET-SELF(\array) {
method SET-SELF(\array) {
$!array := nqp::decont(array);
$!i = -1;
self
}
method new(\array) { nqp::create(self)!SET-SELF(array) }
method new(\array) { nqp::create(self).SET-SELF(array) }

method pull-one() is raw {
($!i = $!i + 1) < nqp::elems($!array)
Expand Down
4 changes: 2 additions & 2 deletions tools/build/makeNATIVE_ARRAY.pl6
Expand Up @@ -282,12 +282,12 @@ for $*IN.lines -> $line {
has int $!i;
has $!array; # Native array we're iterating
method !SET-SELF(\array) {
method SET-SELF(\array) {
$!array := nqp::decont(array);
$!i = -1;
self
}
method new(\array) { nqp::create(self)!SET-SELF(array) }
method new(\array) { nqp::create(self).SET-SELF(array) }
method pull-one() is raw {
($!i = $!i + 1) < nqp::elems($!array)
Expand Down

0 comments on commit a2d8c96

Please sign in to comment.