Skip to content

Commit

Permalink
Make method lookup with the handles trait 13% faster in certain cases
Browse files Browse the repository at this point in the history
By using nqp::can instead of Mu.can, method lookups deferred to an
attribute with the handles trait can be optimized when used with
Whatever or a type object.
  • Loading branch information
Kaiepi committed Mar 14, 2020
1 parent 3d6e8d6 commit af59492
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core.c/traits.pm6
Expand Up @@ -451,7 +451,7 @@ multi sub trait_mod:<handles>(Attribute:D $target, $thunk) {
elsif nqp::istype($expr, Whatever) {
$pkg.^add_fallback(
-> $obj, $name {
so $attr.get_value($obj).can($name);
nqp::can(nqp::decont($attr.get_value: $obj), nqp::decont($name))
},
-> $obj, $name {
-> $self, |c {
Expand Down Expand Up @@ -483,7 +483,7 @@ multi sub trait_mod:<handles>(Attribute:D $target, $thunk) {
else {
$pkg.^add_fallback(
-> $obj, $name {
?$expr.can($name)
nqp::can(nqp::decont($expr), nqp::decont($name))
},
-> $obj, $name {
-> $self, |c {
Expand Down

0 comments on commit af59492

Please sign in to comment.