Skip to content

Commit

Permalink
Use tryfindmethod in reduce_with_match
Browse files Browse the repository at this point in the history
Bringing it in line with reduce. This saves a double lookup of the
method.
  • Loading branch information
jnthn committed Apr 19, 2018
1 parent 1832172 commit 4138401
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/QRegex/Cursor.nqp
Expand Up @@ -644,8 +644,11 @@ role NQPMatchRole is export {

method !reduce_with_match(str $name, str $key, $match) {
my $actions := self.actions;
nqp::findmethod($actions, $name)($actions, $match, $key)
if !nqp::isnull($actions) && nqp::can($actions, $name);
my $method := nqp::isnull($actions)
?? nqp::null()
!! nqp::tryfindmethod($actions, $name);
$method($actions, $match, $key) unless nqp::isnull($method);
self
}

method !shared_type() { ParseShared }
Expand Down

0 comments on commit 4138401

Please sign in to comment.