Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Optimize RANGEPOS a little, which improves Str.succ and Str.pred, tho…
…ugh still not really enough.
  • Loading branch information
jnthn committed Oct 1, 2011
1 parent c857a18 commit dd1307e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/Str.pm
Expand Up @@ -56,16 +56,17 @@ my class Str does Stringy {
my $pos = $str.chars;
while $pos > 0 {
$pos--;
my $ch = $str.substr($pos, 1);
if $RANGECHAR.index($ch).defined {
my str $ch = nqp::substr(nqp::unbox_s($str), nqp::unbox_i($pos), 1);
if nqp::isge_i(nqp::index(nqp::unbox_s($RANGECHAR), $ch, 0), 0) {
my $end = $pos;
while $pos > 0 {
$pos--;
$ch = $str.substr($pos, 1);
last if $ch eq '.';
return ($pos+1, $end) unless $RANGECHAR.index($ch).defined;
$ch = nqp::substr(nqp::unbox_s($str), nqp::unbox_i($pos), 1);
last if nqp::iseq_s($ch, '.');
return ($pos+1, $end)
unless nqp::isge_i(nqp::index(nqp::unbox_s($RANGECHAR), $ch, 0), 0);
}
return ($pos, $end) unless $ch eq '.';
return ($pos, $end) unless nqp::iseq_s($ch, '.');
}
}
return (0, -1);
Expand Down

0 comments on commit dd1307e

Please sign in to comment.