Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Minor optimizations in List/Array.
  • Loading branch information
jnthn committed Jul 25, 2013
1 parent f173b55 commit cc9cf16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/core/Array.pm
Expand Up @@ -89,8 +89,9 @@ class Array {
nqp::findmethod(List, 'REIFY')(self, parcel, nextiter)
}

method STORE_AT_POS(\pos, Mu $v is copy) is rw {
nqp::findmethod(List, 'STORE_AT_POS')(self, pos, $v);
method STORE_AT_POS(Int \pos, Mu $v is copy) is rw {
nqp::bindpos(nqp::getattr(self, List, '$!items'),
nqp::unbox_i(pos), $v)
}

method STORE(|) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/List.pm
Expand Up @@ -182,9 +182,9 @@ my class List does Positional {
}

multi method push(List:D: *@values) {
fail 'Cannot .push to an infinite list' if self.infinite; #MMD?
fail 'Cannot .push an infinite list' if @values.infinite;
my $pos = self.elems;
my $pos = self.gimme(*);
fail 'Cannot .push an infinite list' if $!nextiter.defined;
self.STORE_AT_POS($pos++, @values.shift) while @values.gimme(1);
self;
}
Expand Down Expand Up @@ -370,7 +370,7 @@ my class List does Positional {
parcel
}

method STORE_AT_POS(\pos, Mu \v) is rw {
method STORE_AT_POS(Int \pos, Mu \v) is rw {
nqp::bindpos($!items, nqp::unbox_i(pos), v)
}

Expand Down

0 comments on commit cc9cf16

Please sign in to comment.