Skip to content

Commit

Permalink
Simplify INTERPOLATE_ASSERTION
Browse files Browse the repository at this point in the history
by removing some unused variables and conditionals.
  • Loading branch information
MasterDuke17 committed Nov 7, 2017
1 parent 9655757 commit fa8bc54
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/core/Match.pm
Expand Up @@ -705,22 +705,17 @@ 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'();
my int $maxlen = -1;
my int $pos = nqp::getattr_i(cur, $?CLASS, '$!from');
# 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);
my Match \match := self.$rx;
my int $len = match.pos - match.from;
match.Bool
&& nqp::isgt_i($len,$maxlen)
&& nqp::isle_i(nqp::add_i($pos,$len),nqp::chars(cur.target))
&& nqp::isgt_i($len,-1)
&& nqp::isle_i(nqp::add_i(nqp::getattr_i(cur, $?CLASS, '$!from'),$len),nqp::chars(cur.target))
?? match
!! nqp::isge_i($maxlen,0)
?? cur.'!cursor_pass'(nqp::add_i($pos,$maxlen), '')
!! cur
!! cur
}
method CALL_SUBRULE($rule, |c) {
Expand Down

0 comments on commit fa8bc54

Please sign in to comment.