From 52f44de257681b0213ffd57a8754759c016ef32c Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 4 Jun 2020 17:13:02 -0400 Subject: [PATCH] This introduces a tiny simplification in number parsing. (#910) * This introduces a tiny simplification in number parsing. * Removing unnecessary function. Co-authored-by: Daniel Lemire --- src/generic/stage2/numberparsing.h | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/generic/stage2/numberparsing.h b/src/generic/stage2/numberparsing.h index 56745199..ccc7071f 100644 --- a/src/generic/stage2/numberparsing.h +++ b/src/generic/stage2/numberparsing.h @@ -214,26 +214,6 @@ really_inline bool is_integer(char c) { // this gets compiled to (uint8_t)(c - '0') <= 9 on all decent compilers } -// We need to check that the character following a zero is valid. This is -// probably frequent and it is harder than it looks. We are building all of this -// just to differentiate between 0x1 (invalid), 0,1 (valid) 0e1 (valid)... -const bool structural_or_whitespace_or_exponent_or_decimal_negated[256] = { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, - 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - -really_inline bool -is_not_structural_or_whitespace_or_exponent_or_decimal(unsigned char c) { - return structural_or_whitespace_or_exponent_or_decimal_negated[c]; -} // check quickly whether the next 8 chars are made of digits // at a glance, it looks better than Mula's @@ -393,7 +373,7 @@ really_inline bool parse_number(UNUSED const uint8_t *const src, uint64_t i; // an unsigned int avoids signed overflows (which are bad) if (*p == '0') { // 0 cannot be followed by an integer ++p; - if (is_not_structural_or_whitespace_or_exponent_or_decimal(*p)) { + if (is_integer(*p)) { #ifdef JSON_TEST_NUMBERS // for unit testing found_invalid_number(src); #endif