| 1317 | } |
| 1318 | |
| 1319 | public static long parseInt000Greedy(CharSequence sequence, final int p, int lim) throws NumericException { |
| 1320 | if (lim == p) { |
| 1321 | throw NumericException.instance().put("empty number string"); |
| 1322 | } |
| 1323 | |
| 1324 | boolean negative = sequence.charAt(p) == '-'; |
| 1325 | int i = p; |
| 1326 | if (negative) { |
| 1327 | i++; |
| 1328 | } |
| 1329 | |
| 1330 | if (i >= lim || notDigit(sequence.charAt(i))) { |
| 1331 | throw NumericException.instance().put("not a number: ").put(sequence); |
| 1332 | } |
| 1333 | |
| 1334 | int val = 0; |
| 1335 | for (; i < lim; i++) { |
| 1336 | char c = sequence.charAt(i); |
| 1337 | |
| 1338 | if (notDigit(c)) { |
| 1339 | break; |
| 1340 | } |
| 1341 | |
| 1342 | // val * 10 + (c - '0') |
| 1343 | int r = (val << 3) + (val << 1) - (c - '0'); |
| 1344 | if (r > val) { |
| 1345 | throw NumericException.instance().put("number overflow"); |
| 1346 | } |
| 1347 | val = r; |
| 1348 | } |
| 1349 | |
| 1350 | final int len = i - p; |
| 1351 | |
| 1352 | if (len > 3 || val == Integer.MIN_VALUE && !negative) { |
| 1353 | throw NumericException.instance().put("number overflow"); |
| 1354 | } |
| 1355 | |
| 1356 | while (i - p < 3) { |
| 1357 | val *= 10; |
| 1358 | i++; |
| 1359 | } |
| 1360 | |
| 1361 | return encodeLowHighInts(negative ? val : -val, len); |
| 1362 | } |
| 1363 | |
| 1364 | public static int parseIntQuiet(CharSequence sequence) { |
| 1365 | try { |