Skip to content

Commit

Permalink
Allow common postcircumfix calls to be cached.
Browse files Browse the repository at this point in the history
Before, they could not be because some candidates accepted named args.
Now, the common named-argumentless case can be cached.
  • Loading branch information
jnthn committed Mar 15, 2013
1 parent 5c49111 commit 495550a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/Perl6/Metamodel/BOOTSTRAP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,6 @@ BEGIN {
# new possibles, and that this was not a pure
# type-based result that we can cache.
$new_possibles := [] unless nqp::islist($new_possibles);
$pure_type_result := 0;
}

# Otherwise, may need full bind check.
Expand Down Expand Up @@ -1150,13 +1149,15 @@ BEGIN {
# If we're at a single candidate here, and we also know there's no
# type constraints that follow, we can cache the result.
if nqp::elems(@possibles) == 1 && $pure_type_result {
nqp::scwbdisable();
nqp::bindattr($dcself, Routine, '$!dispatch_cache',
nqp::multicacheadd(
nqp::getattr($dcself, Routine, '$!dispatch_cache'),
$capture,
nqp::atkey(nqp::atpos(@possibles, 0), 'sub')));
nqp::scwbenable();
if nqp::isnull(pir::getattribute__PPs($capture, 'named')) {
nqp::scwbdisable();
nqp::bindattr($dcself, Routine, '$!dispatch_cache',
nqp::multicacheadd(
nqp::getattr($dcself, Routine, '$!dispatch_cache'),
$capture,
nqp::atkey(nqp::atpos(@possibles, 0), 'sub')));
nqp::scwbenable();
}
}

# Perhaps we found nothing but have junctional arguments?
Expand Down

0 comments on commit 495550a

Please sign in to comment.