Skip to content
Permalink
Browse files

Fast-path for integer case of Str.Numeric

  • Loading branch information...
jnthn committed Jun 8, 2019
1 parent 0e7c6e7 commit c361736e0768f81b56b5f9decb736b59f51f3aeb
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/core/Str.pm6
@@ -342,6 +342,12 @@ my class Str does Stringy { # declared in BOOTSTRAP
}

multi method Numeric(Str:D: --> Numeric:D) {
# Fast-path the integer case if there's no '.'.
unless self.contains('.') {
my \rr = nqp::radix_I(10, $!value, 0, 0b10, Int);
return nqp::atpos(rr, 0) if nqp::iseq_i(nqp::atpos(rr, 2), nqp::chars(self));
}

# Handle special empty string
self.trim eq ""
?? 0

0 comments on commit c361736

Please sign in to comment.
You can’t perform that action at this time.