Simplifying function call.

This commit is contained in:
Daniel Lemire 2018-11-28 11:12:28 -05:00
parent 858426c874
commit c1de7662c1
2 changed files with 19 additions and 36 deletions

View File

@ -150,9 +150,9 @@ static inline uint32_t parse_eight_digits_unrolled(const char *chars) {
// Note: a redesign could avoid this function entirely. // Note: a redesign could avoid this function entirely.
// //
static never_inline bool static never_inline bool
parse_highprecision_float(const u8 *const buf, UNUSED size_t len, parse_highprecision_float(const u8 *const buf,
ParsedJson &pj, UNUSED const u32 depth, const u32 offset, ParsedJson &pj, const u32 offset,
UNUSED bool found_zero, bool found_minus) { bool found_minus) {
const char *p = (const char *)(buf + offset); const char *p = (const char *)(buf + offset);
bool negative = false; bool negative = false;
@ -270,9 +270,8 @@ parse_highprecision_float(const u8 *const buf, UNUSED size_t len,
// This function will almost never be called!!! // This function will almost never be called!!!
// //
static never_inline bool parse_large_integer(const u8 *const buf, static never_inline bool parse_large_integer(const u8 *const buf,
UNUSED size_t len, ParsedJson &pj, ParsedJson &pj,
UNUSED const u32 depth, const u32 offset, const u32 offset,
UNUSED bool found_zero,
bool found_minus) { bool found_minus) {
const char *p = (const char *)(buf + offset); const char *p = (const char *)(buf + offset);
@ -345,9 +344,9 @@ static never_inline bool parse_large_integer(const u8 *const buf,
// parse the number at buf + offset // parse the number at buf + offset
// define JSON_TEST_NUMBERS for unit testing // define JSON_TEST_NUMBERS for unit testing
static really_inline bool parse_number(const u8 *const buf, UNUSED size_t len, static really_inline bool parse_number(const u8 *const buf,
ParsedJson &pj, UNUSED const u32 depth, ParsedJson &pj,
const u32 offset, UNUSED bool found_zero, const u32 offset,
bool found_minus) { bool found_minus) {
const char *p = (const char *)(buf + offset); const char *p = (const char *)(buf + offset);
bool negative = false; bool negative = false;
@ -464,7 +463,7 @@ static really_inline bool parse_number(const u8 *const buf, UNUSED size_t len,
if (unlikely(digitcount >= 19)) { // this is uncommon!!! if (unlikely(digitcount >= 19)) { // this is uncommon!!!
// this is almost never going to get called!!! // this is almost never going to get called!!!
// we start anew, going slowly!!! // we start anew, going slowly!!!
return parse_highprecision_float(buf, len, pj, depth, offset, found_zero, return parse_highprecision_float(buf, pj, offset,
found_minus); found_minus);
} }
/////////// ///////////
@ -493,7 +492,7 @@ static really_inline bool parse_number(const u8 *const buf, UNUSED size_t len,
} }
} else { } else {
if (unlikely(digitcount >= 19)) { // this is uncommon!!! if (unlikely(digitcount >= 19)) { // this is uncommon!!!
return parse_large_integer(buf, len, pj, depth, offset, found_zero, return parse_large_integer(buf, pj, offset,
found_minus); found_minus);
} }
pj.write_tape_s64(i); pj.write_tape_s64(i);

View File

@ -140,13 +140,7 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
} }
pj.write_tape(0, c); pj.write_tape(0, c);
break; break;
case '0': { case '0':
if (!parse_number(buf, len, pj, depth, idx, true, false)) {
goto fail;
}
break;
}
case '1': case '1':
case '2': case '2':
case '3': case '3':
@ -156,13 +150,13 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
case '7': case '7':
case '8': case '8':
case '9': { case '9': {
if (!parse_number(buf, len, pj, depth, idx, false, false)) { if (!parse_number(buf, pj, idx, false)) {
goto fail; goto fail;
} }
break; break;
} }
case '-': { case '-': {
if (!parse_number(buf, len, pj, depth, idx, false, true)) { if (!parse_number(buf, pj, idx, true)) {
goto fail; goto fail;
} }
break; break;
@ -238,12 +232,7 @@ object_key_state:
} }
pj.write_tape(0, c); pj.write_tape(0, c);
break; break;
case '0': { case '0':
if (!parse_number(buf, len, pj, depth, idx, true, false)) {
goto fail;
}
break;
}
case '1': case '1':
case '2': case '2':
case '3': case '3':
@ -253,13 +242,13 @@ object_key_state:
case '7': case '7':
case '8': case '8':
case '9': { case '9': {
if (!parse_number(buf, len, pj, depth, idx, false, false)) { if (!parse_number(buf, pj, idx, false)) {
goto fail; goto fail;
} }
break; break;
} }
case '-': { case '-': {
if (!parse_number(buf, len, pj, depth, idx, false, true)) { if (!parse_number(buf, pj, idx, true)) {
goto fail; goto fail;
} }
break; break;
@ -360,12 +349,7 @@ main_array_switch:
pj.write_tape(0, c); pj.write_tape(0, c);
break; // goto array_continue; break; // goto array_continue;
case '0': { case '0':
if (!parse_number(buf, len, pj, depth, idx, true, false)) {
goto fail;
}
break; // goto array_continue;
}
case '1': case '1':
case '2': case '2':
case '3': case '3':
@ -375,13 +359,13 @@ main_array_switch:
case '7': case '7':
case '8': case '8':
case '9': { case '9': {
if (!parse_number(buf, len, pj, depth, idx, false, false)) { if (!parse_number(buf, pj, idx, false)) {
goto fail; goto fail;
} }
break; // goto array_continue; break; // goto array_continue;
} }
case '-': { case '-': {
if (!parse_number(buf, len, pj, depth, idx, false, true)) { if (!parse_number(buf, pj, idx, true)) {
goto fail; goto fail;
} }
break; // goto array_continue; break; // goto array_continue;