Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make List.shift cheaper in the (common) case that we have an element.…
… This in turn makes list assignment cheaper, wich does a gimme to ensure there is an element, followed by a shift.
  • Loading branch information
jnthn committed Oct 1, 2011
1 parent f1eba49 commit 27090e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/List.pm
Expand Up @@ -184,7 +184,7 @@ my class List does Positional {

method shift() is rw {
# make sure we have at least one item, then shift+return it
self.gimme(1)
nqp::islist($!items) && nqp::existspos($!items, 0) || self.gimme(1)
?? nqp::shift($!items)
!! fail 'Element shifted from empty list';
}
Expand Down

0 comments on commit 27090e7

Please sign in to comment.