Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use eqat or ord for length-one literals in regex.
  • Loading branch information
timo committed Nov 20, 2013
1 parent cf04d56 commit af22bef
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/vm/parrot/QAST/Compiler.nqp
Expand Up @@ -1462,10 +1462,17 @@ class QAST::Compiler is HLL::Compiler {
my $cmpop := $node.negate ?? 'eq' !! 'ne';
$ops.push_pirop('add', '$I11', %*REG<pos>, $litlen);
$ops.push_pirop('gt', '$I11', %*REG<eos>, %*REG<fail>);
$ops.push_pirop('substr', '$S10', %*REG<tgt>, %*REG<pos>, $litlen);
$ops.push_pirop('downcase', '$S10', '$S10')
if $node.subtype eq 'ignorecase';
$ops.push_pirop($cmpop, '$S10', $litpost, %*REG<fail>);
if $node.subtype eq 'ignorecase' {
$ops.push_pirop('substr', '$S10', %*REG<tgt>, %*REG<pos>, $litlen);
$ops.push_pirop('downcase', '$S10', '$S10');
$ops.push_pirop($cmpop, '$S10', $litpost, %*REG<fail>);
} elsif $litlen == 1 {
$ops.push_pirop('ord', '$I11', %*REG<tgt>, %*REG<pos>);
$ops.push_pirop($cmpop, '$I11', nqp::ord($litconst), %*REG<fail>);
} else {
$ops.push_pirop('nqp_string_equal_at', '$I11', %*REG<tgt>, $litpost, %*REG<pos>);
$ops.push_pirop($cmpop, '$I11', 1, %*REG<fail>);
}
$ops.push_pirop('add', %*REG<pos>, $litlen);
$ops;
}
Expand Down

0 comments on commit af22bef

Please sign in to comment.