Skip to content

Commit 96c2411

Browse files
committed
Use nqp::tryfindmethod in Cursor!reduce
Seems to give a few percent speedup on JSON::Tiny, by avoiding the need for double lookups.
1 parent 1f75964 commit 96c2411

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/QRegex/Cursor.nqp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,10 @@ role NQPMatchRole is export {
642642

643643
method !reduce(str $name) {
644644
my $actions := self.actions;
645-
nqp::findmethod($actions, $name)($actions, self.MATCH)
646-
if !nqp::isnull($actions) && nqp::can($actions, $name);
645+
my $method := nqp::isnull($actions)
646+
?? nqp::null()
647+
!! nqp::tryfindmethod($actions, $name);
648+
$method($actions, self.MATCH) unless nqp::isnull($method);
647649
self;
648650
}
649651

0 commit comments

Comments
 (0)