@@ -3,9 +3,9 @@ package core
33
44import java .security .MessageDigest
55import scala .io .Codec
6+ import Int .MaxValue
67import Names ._ , StdNames ._ , Contexts ._ , Symbols ._ , Flags ._ , NameKinds ._ , Types ._
7- import scala .internal .Chars
8- import Chars .isOperatorPart
8+ import scala .internal .Chars .{isOperatorPart , digit2int }
99import Definitions ._
1010import nme ._
1111import Decorators .concat
@@ -207,14 +207,18 @@ object NameOps {
207207
208208 /** Parsed function arity for function with some specific prefix */
209209 private def functionArityFor (prefix : String ): Int =
210- if (name.startsWith(prefix)) {
211- val suffix = name.toString.substring(prefix.length)
212- if (suffix.matches( " \\ d+ " ))
213- suffix.toInt
210+ inline val MaxSafeInt = MaxValue / 10
211+ val first = name.firstPart
212+ def collectDigits ( acc : Int , idx : Int ) : Int =
213+ if idx == first.length then acc
214214 else
215- - 1
216- }
217- else - 1
215+ val d = digit2int(first(idx), 10 )
216+ if d < 0 || acc > MaxSafeInt then - 1
217+ else collectDigits(acc * 10 + d, idx + 1 )
218+ if first.startsWith(prefix) && prefix.length < first.length then
219+ collectDigits(0 , prefix.length)
220+ else
221+ - 1
218222
219223 /** The name of the generic runtime operation corresponding to an array operation */
220224 def genericArrayOp : TermName = name match {
0 commit comments