Permalink
Browse files

Make int @a.append(1) 1800x faster

by not making it take the long, slurpy array -> flattening route
  • Loading branch information...
lizmat committed Feb 28, 2016
1 parent fb74abc commit c70a18e9cd4aff36c2c7a6b8f9a62770c8c533b3
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/core/native_array.pm
@@ -88,6 +88,14 @@ my class array does Iterable is repr('VMArray') {
expected => T,
).throw;
}
multi method append(array:D: int $value) {
nqp::push_i(self, $value);
self
}
multi method append(array:D: Int $value) {
nqp::push_i(self, $value);
self
}
multi method append(array:D: @values) {
fail X::Cannot::Lazy.new(:action<push>, :what(self.^name))
if @values.is-lazy;

0 comments on commit c70a18e

Please sign in to comment.