Skip to content

Commit c1de766

Browse files
committed
Simplifying function call.
1 parent 858426c commit c1de766

2 files changed

Lines changed: 19 additions & 36 deletions

File tree

include/jsonparser/numberparsing.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ static inline uint32_t parse_eight_digits_unrolled(const char *chars) {
150150
// Note: a redesign could avoid this function entirely.
151151
//
152152
static never_inline bool
153-
parse_highprecision_float(const u8 *const buf, UNUSED size_t len,
154-
ParsedJson &pj, UNUSED const u32 depth, const u32 offset,
155-
UNUSED bool found_zero, bool found_minus) {
153+
parse_highprecision_float(const u8 *const buf,
154+
ParsedJson &pj, const u32 offset,
155+
bool found_minus) {
156156
const char *p = (const char *)(buf + offset);
157157

158158
bool negative = false;
@@ -270,9 +270,8 @@ parse_highprecision_float(const u8 *const buf, UNUSED size_t len,
270270
// This function will almost never be called!!!
271271
//
272272
static never_inline bool parse_large_integer(const u8 *const buf,
273-
UNUSED size_t len, ParsedJson &pj,
274-
UNUSED const u32 depth, const u32 offset,
275-
UNUSED bool found_zero,
273+
ParsedJson &pj,
274+
const u32 offset,
276275
bool found_minus) {
277276
const char *p = (const char *)(buf + offset);
278277

@@ -345,9 +344,9 @@ static never_inline bool parse_large_integer(const u8 *const buf,
345344

346345
// parse the number at buf + offset
347346
// define JSON_TEST_NUMBERS for unit testing
348-
static really_inline bool parse_number(const u8 *const buf, UNUSED size_t len,
349-
ParsedJson &pj, UNUSED const u32 depth,
350-
const u32 offset, UNUSED bool found_zero,
347+
static really_inline bool parse_number(const u8 *const buf,
348+
ParsedJson &pj,
349+
const u32 offset,
351350
bool found_minus) {
352351
const char *p = (const char *)(buf + offset);
353352
bool negative = false;
@@ -464,7 +463,7 @@ static really_inline bool parse_number(const u8 *const buf, UNUSED size_t len,
464463
if (unlikely(digitcount >= 19)) { // this is uncommon!!!
465464
// this is almost never going to get called!!!
466465
// we start anew, going slowly!!!
467-
return parse_highprecision_float(buf, len, pj, depth, offset, found_zero,
466+
return parse_highprecision_float(buf, pj, offset,
468467
found_minus);
469468
}
470469
///////////
@@ -493,7 +492,7 @@ static really_inline bool parse_number(const u8 *const buf, UNUSED size_t len,
493492
}
494493
} else {
495494
if (unlikely(digitcount >= 19)) { // this is uncommon!!!
496-
return parse_large_integer(buf, len, pj, depth, offset, found_zero,
495+
return parse_large_integer(buf, pj, offset,
497496
found_minus);
498497
}
499498
pj.write_tape_s64(i);

src/stage34_unified.cpp

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,7 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
140140
}
141141
pj.write_tape(0, c);
142142
break;
143-
case '0': {
144-
if (!parse_number(buf, len, pj, depth, idx, true, false)) {
145-
goto fail;
146-
}
147-
148-
break;
149-
}
143+
case '0':
150144
case '1':
151145
case '2':
152146
case '3':
@@ -156,13 +150,13 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
156150
case '7':
157151
case '8':
158152
case '9': {
159-
if (!parse_number(buf, len, pj, depth, idx, false, false)) {
153+
if (!parse_number(buf, pj, idx, false)) {
160154
goto fail;
161155
}
162156
break;
163157
}
164158
case '-': {
165-
if (!parse_number(buf, len, pj, depth, idx, false, true)) {
159+
if (!parse_number(buf, pj, idx, true)) {
166160
goto fail;
167161
}
168162
break;
@@ -238,12 +232,7 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
238232
}
239233
pj.write_tape(0, c);
240234
break;
241-
case '0': {
242-
if (!parse_number(buf, len, pj, depth, idx, true, false)) {
243-
goto fail;
244-
}
245-
break;
246-
}
235+
case '0':
247236
case '1':
248237
case '2':
249238
case '3':
@@ -253,13 +242,13 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
253242
case '7':
254243
case '8':
255244
case '9': {
256-
if (!parse_number(buf, len, pj, depth, idx, false, false)) {
245+
if (!parse_number(buf, pj, idx, false)) {
257246
goto fail;
258247
}
259248
break;
260249
}
261250
case '-': {
262-
if (!parse_number(buf, len, pj, depth, idx, false, true)) {
251+
if (!parse_number(buf, pj, idx, true)) {
263252
goto fail;
264253
}
265254
break;
@@ -360,12 +349,7 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
360349
pj.write_tape(0, c);
361350
break; // goto array_continue;
362351

363-
case '0': {
364-
if (!parse_number(buf, len, pj, depth, idx, true, false)) {
365-
goto fail;
366-
}
367-
break; // goto array_continue;
368-
}
352+
case '0':
369353
case '1':
370354
case '2':
371355
case '3':
@@ -375,13 +359,13 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
375359
case '7':
376360
case '8':
377361
case '9': {
378-
if (!parse_number(buf, len, pj, depth, idx, false, false)) {
362+
if (!parse_number(buf, pj, idx, false)) {
379363
goto fail;
380364
}
381365
break; // goto array_continue;
382366
}
383367
case '-': {
384-
if (!parse_number(buf, len, pj, depth, idx, false, true)) {
368+
if (!parse_number(buf, pj, idx, true)) {
385369
goto fail;
386370
}
387371
break; // goto array_continue;

0 commit comments

Comments
 (0)