Skip to content

Commit

Permalink
Optimize Tap.close a little
Browse files Browse the repository at this point in the history
This restructuring avoids a Code allocation each time.
  • Loading branch information
jnthn committed Jan 15, 2018
1 parent 163f275 commit 83a619e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/Supply.pm
Expand Up @@ -14,9 +14,10 @@ my class Tap {
}

method close() {
if &!on-close {
my \close-result = &!on-close();
await close-result if nqp::istype(close-result, Promise);
my &closer := &!on-close;
my \close-result = &closer ?? closer() !! Nil;
if nqp::istype(close-result, Promise) {
await close-result;
}
True
}
Expand Down

0 comments on commit 83a619e

Please sign in to comment.