Skip to content
Permalink
Browse files

Speed up storing non-iterables in Buf/Blob

Use nqp::push_i instead of .ASSIGN-POS.  This also makes Blob.new(...) work
(spotted while writing tests).
  • Loading branch information...
lizmat committed Feb 12, 2019
1 parent bfadefa commit 05b9aa0df802ab40b44404185434a3d0471db00e
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/core/Buf.pm6
@@ -66,7 +66,7 @@ my role Blob[::T = uint8] does Positional[T] does Stringy is repr('VMArray') is
multi method STORE(Blob:D: Any:D \non-iterable, :$INITIALIZE) {
X::Assignment::RO.new(:value(self)).throw unless $INITIALIZE;
my int $elems = non-iterable.elems;
self.ASSIGN-POS($_, non-iterable.AT-POS($_)) for ^$elems;
nqp::push_i(self,non-iterable.AT-POS($_)) for ^$elems;
self
}

@@ -719,8 +719,9 @@ my role Buf[::T = uint8] does Blob[T] is repr('VMArray') is array_type(T) {
}
multi method STORE(Buf:D: Any:D \non-iterable) {
my int $elems = non-iterable.elems;
self.ASSIGN-POS($_, non-iterable.AT-POS($_)) for ^$elems;
nqp::setelems(self,$elems)
nqp::setelems(self,0);
nqp::push_i(self,non-iterable.AT-POS($_)) for ^$elems;
self
}

#?if moar

0 comments on commit 05b9aa0

Please sign in to comment.
You can’t perform that action at this time.