Skip to content

Commit

Permalink
Merge pull request #1145 from MasterDuke17/simplify_ignoremark_and_ig…
Browse files Browse the repository at this point in the history
…norecase_in_INTERPOLATE

Simplify ignore(mark|case) handling in INTERPOLATE
  • Loading branch information
lizmat committed Aug 31, 2017
2 parents 8b5d283 + 215a5fa commit 067f540
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions src/core/Match.pm
Expand Up @@ -328,39 +328,19 @@ my class Match is Capture is Cool does NQPMatchRole {
$match = nqp::eqat($tgt, $topic_str, $pos)
}

# ignoremark(+ignorecase?)
elsif $m {
my int $k = -1;

# ignorecase+ignoremark
if $i {
my str $tgt_fc = nqp::fc(nqp::substr($tgt,$pos,$len));
my str $topic_fc = nqp::fc($topic_str);
Nil while nqp::islt_i(++$k,$len)
&& nqp::iseq_i(
nqp::ordbaseat($tgt_fc, nqp::add_i($pos,$k)),
nqp::ordbaseat($topic_fc, $k)
);
}

# ignoremark
else {
Nil while nqp::islt_i(++$k, $len)
&& nqp::iseq_i(
nqp::ordbaseat($tgt, nqp::add_i($pos,$k)),
nqp::ordbaseat($topic_str, $k)
);
}
# ignoremark+ignorecase
elsif $m && $i {
$match = nqp::indexicim($tgt, $topic_str, $pos) >= 0;
}

$match = nqp::iseq_i($k,$len); # match if completed
# ignoremark
elsif $m {
$match = nqp::indexim($tgt, $topic_str, $pos) >= 0;
}

# ignorecase
else {
$match = nqp::iseq_s(
nqp::fc(nqp::substr($tgt, $pos, $len)),
nqp::fc($topic_str)
)
elsif $i {
$match = nqp::indexic($tgt, $topic_str, $pos) >= 0;
}

if $match
Expand Down

0 comments on commit 067f540

Please sign in to comment.