Skip to content

Commit

Permalink
Make internal RETURN-LIST sub faster for common case
Browse files Browse the repository at this point in the history
If we're returning / take get a List, then probably it has more than 1
element in it.
  • Loading branch information
lizmat committed Feb 28, 2018
1 parent 51fccdf commit 3a4056b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/control.pm
Expand Up @@ -22,11 +22,11 @@ sub THROW-NIL(int $type --> Nil) {

sub RETURN-LIST(Mu \list) is raw {
my Mu $storage := nqp::getattr(list, List, '$!reified');
nqp::iseq_i(nqp::elems($storage), 0)
?? Nil
!! (nqp::iseq_i(nqp::elems($storage), 1)
?? nqp::shift($storage)
!! list)
nqp::isgt_i(nqp::elems($storage),1)
?? list
!! nqp::elems($storage)
?? nqp::shift($storage)
!! Nil
}

proto sub return-rw(|) {*}
Expand Down

0 comments on commit 3a4056b

Please sign in to comment.