@@ -16,7 +16,6 @@ final private[scala] object StringParsers {
16
16
private final val longOverflowBoundary = - 922337203685477580L
17
17
private final val longOverflowDigit = 9
18
18
19
-
20
19
@ inline
21
20
private [this ] final def decValue (ch : Char ): Int = java.lang.Character .digit(ch, 10 )
22
21
@@ -38,6 +37,9 @@ final private[scala] object StringParsers {
38
37
rec(1 , agg)
39
38
}
40
39
40
+ @ inline
41
+ private [this ] final def isDigit (c : Char ): Boolean = c >= '0' && c <= '9'
42
+
41
43
// bool
42
44
@ inline
43
45
final def parseBool (from : String ): Option [Boolean ] =
@@ -240,19 +242,20 @@ final private[scala] object StringParsers {
240
242
// but not just .
241
243
val startChar = format.charAt(startIndex)
242
244
if (startChar == '.' ) {
243
- val noSignificant = skipIndexWhile(ch => ch >= '0' && ch <= '9' , startIndex + 1 , endIndex)
244
- (noSignificant != startIndex + 1 ) && { // not just "." or ".Exxx"
245
+ val noSignificant = skipIndexWhile(isDigit, startIndex + 1 , endIndex)
246
+ // a digit is required followed by optional exp
247
+ (noSignificant > startIndex + 1 ) && (noSignificant >= endIndex || {
245
248
val e = format.charAt(noSignificant)
246
249
(e == 'e' || e == 'E' ) && expOK(noSignificant + 1 , endIndex)
247
- }
250
+ })
248
251
}
249
- else if (startChar >= '0' && startChar <= '9' ) {
252
+ else if (isDigit( startChar)) {
250
253
// one set of digits, then optionally a period, then optionally another set of digits, then optionally an exponent
251
- val noInt = skipIndexWhile(ch => ch >= '0' && ch <= '9' , startIndex, endIndex)
254
+ val noInt = skipIndexWhile(isDigit , startIndex, endIndex)
252
255
(noInt == endIndex) || { // just the digits
253
256
val afterIntChar = format.charAt(noInt)
254
257
if (afterIntChar == '.' ) {
255
- val noSignificant = skipIndexWhile(ch => ch >= '0' && ch <= '9' , noInt + 1 , endIndex)
258
+ val noSignificant = skipIndexWhile(isDigit , noInt + 1 , endIndex)
256
259
(noSignificant >= endIndex) || { // no exponent
257
260
val e = format.charAt(noSignificant)
258
261
(e == 'e' || e == 'E' ) && expOK(noSignificant + 1 , endIndex)
@@ -307,4 +310,4 @@ final private[scala] object StringParsers {
307
310
if (checkFloatFormat(from)) Some (java.lang.Double .parseDouble(from))
308
311
else None
309
312
310
- }
313
+ }
0 commit comments