MCPcopy Create free account
hub / github.com/questdb/questdb / parseInt000Greedy

Method parseInt000Greedy

core/src/main/java/io/questdb/std/Numbers.java:1319–1362  ·  view source on GitHub ↗
(CharSequence sequence, final int p, int lim)

Source from the content-addressed store, hash-verified

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 {

Callers 8

testParse000Greedy0Method · 0.95
testParse000Greedy1Method · 0.95
testParse000Greedy2Method · 0.95
testParse000Greedy3Method · 0.95
testParse000Greedy4Method · 0.95
parseMethod · 0.95
parseMethod · 0.95
parseMethod · 0.95

Calls 5

instanceMethod · 0.95
notDigitMethod · 0.95
encodeLowHighIntsMethod · 0.95
putMethod · 0.65
charAtMethod · 0.45

Tested by 5

testParse000Greedy0Method · 0.76
testParse000Greedy1Method · 0.76
testParse000Greedy2Method · 0.76
testParse000Greedy3Method · 0.76
testParse000Greedy4Method · 0.76