Permalink
Browse files

[regex] avoid an unnecessary comparison

when the index is op is used, it always returns -1 for start indexes
beyond the string length
  • Loading branch information...
1 parent 2c393d3 commit b8a7bbba70516d73cb068fe583366ed24c53c6cf @moritz moritz committed Oct 19, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/vm/parrot/QAST/Compiler.nqp
@@ -1568,7 +1568,9 @@ class QAST::Compiler is HLL::Compiler {
$ops.push_pirop('index', %*REG<pos>, %*REG<tgt>, self.rxescape($node[0]), %*REG<pos>);
$ops.push_pirop('eq', %*REG<pos>, -1, %*REG<fail>);
}
- $ops.push_pirop('gt', %*REG<pos>, %*REG<eos>, %*REG<fail>);
+ else {
+ $ops.push_pirop('gt', %*REG<pos>, %*REG<eos>, %*REG<fail>);
+ }
$ops.push_pirop('repr_bind_attr_int', %*REG<cur>, %*REG<curclass>, '"$!from"', %*REG<pos>);
$ops.push($scanlabel);
self.regex_mark($ops, $looplabel, %*REG<pos>, 0);

0 comments on commit b8a7bbb

Please sign in to comment.