From 533a2ad9e904a8d1b1b425acb29e590b7de71daf Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Mon, 30 Dec 2019 21:44:09 +0100 Subject: [PATCH] Make `take-rw foo` about 20% faster By not using the helper THROW sub, but instead do all of the stuff inside `take-rw`. Also fix containerization issue that I noticed in `take` while working on `take-rw`. --- src/core.c/control.pm6 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core.c/control.pm6 b/src/core.c/control.pm6 index eed02fadd2e..42c10f0fb27 100644 --- a/src/core.c/control.pm6 +++ b/src/core.c/control.pm6 @@ -52,7 +52,13 @@ multi sub return(**@x is raw --> Nil) { proto sub take-rw(|) {*} multi sub take-rw() { die "take-rw without parameters doesn't make sense" } -multi sub take-rw(\x) { THROW(nqp::const::CONTROL_TAKE, x) } +multi sub take-rw(\value) { + my Mu $ex := nqp::newexception(); + nqp::setpayload($ex,value); + nqp::setextype($ex,nqp::const::CONTROL_TAKE); + nqp::throw($ex); + value +} multi sub take-rw(|) { THROW(nqp::const::CONTROL_TAKE,RETURN-LIST(nqp::p6argvmarray)) } @@ -61,10 +67,10 @@ proto sub take(|) {*} multi sub take() { die "take without parameters doesn't make sense" } multi sub take(\value) { my Mu $ex := nqp::newexception(); - nqp::setpayload($ex,nqp::p6recont_ro(value)); + nqp::setpayload($ex,my \out := nqp::p6recont_ro(value)); nqp::setextype($ex,nqp::const::CONTROL_TAKE); nqp::throw($ex); - value + out } multi sub take(|) { THROW(