Skip to content

Commit

Permalink
Make take-rw foo about 20% faster
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
lizmat committed Dec 30, 2019
1 parent a91813d commit 533a2ad
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core.c/control.pm6
Expand Up @@ -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))
}
Expand All @@ -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(
Expand Down

0 comments on commit 533a2ad

Please sign in to comment.