Permalink
Browse files

Tweaks in List.unshift / List.push

  • Loading branch information...
1 parent f8e970b commit 34131dbf6773cd6d426ae439b168eca56b2963eb @lizmat lizmat committed Jul 29, 2013
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/core/List.pm
View
@@ -183,9 +183,9 @@ my class List does Positional {
multi method push(List:D: *@values) {
fail 'Cannot .push an infinite list' if @values.infinite;
- my $elems = self.gimme(*);
+ self.gimme(*);
fail 'Cannot .push to an infinite list' if $!nextiter.defined;
- nqp::bindattr( self, List, '$!items', nqp::list() ) if $elems == 0;
+ nqp::p6listitems(self);
nqp::push( $!items, @values.shift ) while @values.gimme(1);
self;
}
@@ -237,11 +237,10 @@ my class List does Positional {
!! fail 'Element shifted from empty list';
}
- multi method unshift(List:D: *@elems) {
+ multi method unshift(List:D: *@values) {
+ fail 'Cannot .unshift an infinite list' if @values.infinite;
nqp::p6listitems(self);
- while @elems {
- nqp::unshift($!items, @elems.pop)
- }
+ nqp::unshift($!items, @values.pop) while @values.gimme(1);
self
}

0 comments on commit 34131db

Please sign in to comment.