Skip to content

Commit

Permalink
Fix "١٢٣".Numeric and "١٢٣".Int
Browse files Browse the repository at this point in the history
- a0e5841 broke this, apparently MoarVM only uses 0..9 for implicit conversion
- makes "123".Numeric.Int about 1.7x **slower**
- perhaps we need a CCLASS_DECIMAL class to quickly check for 0..9
  This would allow the speedup to be brought back again
- fixes R#3694
  • Loading branch information
lizmat committed May 15, 2020
1 parent b874c68 commit c2e8b22
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core.c/Str.pm6
Expand Up @@ -784,9 +784,9 @@ my class Str does Stringy { # declared in BOOTSTRAP
nqp::const::CCLASS_NUMERIC,self,0,nqp::chars(self)),
nqp::chars(self)
) ?? nqp::isle_i(nqp::chars($!value),18) # upto 18 digits can be native
?? (my int $ = $!value) # quick conversion, "" also ok
!! nqp::atpos(nqp::radix_I(10,self,0,0b10,Int),0)
!! nqp::atpos( # no period, so parse as Int
?? nqp::atpos(nqp::radix(10,self,0,0),0) # quick conversion, "" also
!! nqp::atpos(nqp::radix_I(10,self,0,0,Int),0)
!! nqp::atpos( # try parsing as an Int
(my $n := nqp::radix_I(10,self,0,0b10,Int)),
2
) == nqp::chars(self)
Expand Down

0 comments on commit c2e8b22

Please sign in to comment.