Skip to content
Permalink
Browse files

Avoid a throw-away cursor per <$rx> interpolation

This is worth at least 5% on a benchmark doing such interpolations in
a loop.
  • Loading branch information...
jnthn committed Dec 13, 2018
1 parent 6c2f3c8 commit 62243cd93a342d039db6324e3c0766b322fa4bbd
Showing with 2 additions and 4 deletions.
  1. +2 −4 src/core/Match.pm6
@@ -719,8 +719,6 @@ my class Match is Capture is Cool does NQPMatchRole {
}
multi method INTERPOLATE_ASSERTION(Mu:D \var, int \im, int \monkey, $, $, \context) {
my \cur = self.'!cursor_start_cur'();
# We are in a regex assertion, the strings we get will be
# treated as regex rules.
my $rx := MAKE_REGEX(var,im == 1 || im == 3,im == 2 || im == 3,monkey,context);
@@ -729,9 +727,9 @@ my class Match is Capture is Cool does NQPMatchRole {
match.Bool
&& nqp::isgt_i($len,-1)
&& nqp::isle_i(nqp::add_i(nqp::getattr_i(cur, $?CLASS, '$!from'),$len),nqp::chars(cur.target))
&& nqp::isle_i(nqp::add_i(nqp::getattr_i(self, $?CLASS, '$!pos'),$len),nqp::chars(self.target))
?? match
!! cur
!! self.'!cursor_start_fail'()
}
method CALL_SUBRULE($rule, |c) {

0 comments on commit 62243cd

Please sign in to comment.
You can’t perform that action at this time.