Permalink
Browse files

Small optimizations to number parsing.

  • Loading branch information...
jnthn committed Jun 29, 2014
1 parent a9a5002 commit 8900d97dd7a0e9333b3f00c727b647f3f76e503b
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/core/Str.pm
View
@@ -299,7 +299,12 @@ my class Str does Stringy { # declared in BOOTSTRAP
$pos = $p;
$int := nqp::atpos($parse, 0);
$ch = nqp::islt_i($pos, $eos) && nqp::ord($str, $pos);
if nqp::isge_i($pos, $eos) {
return $int;
}
else {
$ch = nqp::ord($str, $pos);
}
}
# Fraction, if any
@@ -476,7 +481,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
my $denom := parse-simple-number();
$result := $result.WHAT === Int && $denom.WHAT === Int
$result := nqp::istype($result, Int) && nqp::istype($denom, Int)
?? Rat.new($result, $denom)
!! $result / $denom;
}

0 comments on commit 8900d97

Please sign in to comment.