@@ -3,9 +3,9 @@ package core
3
3
4
4
import java .security .MessageDigest
5
5
import scala .io .Codec
6
+ import Int .MaxValue
6
7
import Names ._ , StdNames ._ , Contexts ._ , Symbols ._ , Flags ._ , NameKinds ._ , Types ._
7
- import scala .internal .Chars
8
- import Chars .isOperatorPart
8
+ import scala .internal .Chars .{isOperatorPart , digit2int }
9
9
import Definitions ._
10
10
import nme ._
11
11
import Decorators .concat
@@ -207,14 +207,18 @@ object NameOps {
207
207
208
208
/** Parsed function arity for function with some specific prefix */
209
209
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
214
214
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
218
222
219
223
/** The name of the generic runtime operation corresponding to an array operation */
220
224
def genericArrayOp : TermName = name match {
0 commit comments