From 3a4056bf324f30f0298bb0a55206cd33ddc660f5 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Wed, 28 Feb 2018 17:23:55 +0100 Subject: [PATCH] Make internal RETURN-LIST sub faster for common case If we're returning / take get a List, then probably it has more than 1 element in it. --- src/core/control.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/control.pm b/src/core/control.pm index 348b9122e0d..983d20a3fb7 100644 --- a/src/core/control.pm +++ b/src/core/control.pm @@ -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(|) {*}