Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make my int @A = Range about 1000x faster
  • Loading branch information
lizmat committed Mar 16, 2015
1 parent 67156c1 commit 051c602
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/native_array.pm
Expand Up @@ -46,6 +46,21 @@ class array is Iterable is repr('VMArray') {
}
self
}
multi method STORE(array:D: Range:D $range) {
my int $val = $range.min;
$val = $val + 1 if $range.excludes-min;
my int $max = $range.max;
$max = $max - 1 if $range.excludes-max;
nqp::setelems(self, $max - $val + 1);

my int $i;
while $val <= $max {
nqp::bindpos_i(self, $i, $val);
$val = $val + 1;
$i = $i + 1;
}
self
}

multi method push(array:D: int $value) {
nqp::push_i(self, $value);
Expand Down

0 comments on commit 051c602

Please sign in to comment.