Skip to content

Commit cedea6d

Browse files
committed
literal with ignorecase now caches lc results
of both the haystack and the needle.
1 parent 778d1a1 commit cedea6d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/vm/moar/QAST/QASTRegexCompilerMAST.nqp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,19 @@ class QAST::MASTRegexCompiler {
661661
op($op, $s0, %!reg<zero>, sval(nqp::lc($c) ~ nqp::uc($c)), %!reg<fail>),
662662
]);
663663
}
664+
elsif $node.subtype eq 'ignorecase' {
665+
# XXX ignorecase may want fc instead of lc
666+
my $cmpop := $node.negate ?? 'if_i' !! 'unless_i';
667+
nqp::push(@ins, op('const_s', $s0, sval(nqp::lc($litconst))));
668+
unless nqp::existskey(%!reg, 'haystacklc') {
669+
%!reg<haystacklc> := $!regalloc.fresh_s();
670+
nqp::push(@ins, op('lc', %!reg<haystacklc>, %!reg<tgt>));
671+
}
672+
nqp::push(@ins, op('eqat_s', $i0, %!reg<haystacklc>, $s0, %!reg<pos>));
673+
nqp::push(@ins, op($cmpop, $i0, %!reg<fail>));
674+
}
664675
else {
665-
my $eq_op := $node.subtype eq 'ignorecase' ?? 'eqatic_s' !!
666-
$node.subtype eq 'ignoremark' ?? 'eqatim_s' !! 'eqat_s';
676+
my $eq_op := $node.subtype eq 'ignoremark' ?? 'eqatim_s' !! 'eqat_s';
667677
my $cmpop := $node.negate ?? 'if_i' !! 'unless_i';
668678
nqp::push(@ins, op('const_s', $s0, sval($litconst)));
669679
nqp::push(@ins, op($eq_op, $i0, %!reg<tgt>, $s0, %!reg<pos>));

0 commit comments

Comments
 (0)