1+ namespace numberparsing {
12
23// Allowable floating-point values range
34// std::numeric_limits<double>::lowest() to std::numeric_limits<double>::max(),
@@ -75,7 +76,7 @@ static const double power_of_ten[] = {
7576 1e295 , 1e296 , 1e297 , 1e298 , 1e299 , 1e300 , 1e301 , 1e302 , 1e303 ,
7677 1e304 , 1e305 , 1e306 , 1e307 , 1e308 };
7778
78- static inline bool is_integer (char c) {
79+ really_inline bool is_integer (char c) {
7980 return (c >= ' 0' && c <= ' 9' );
8081 // this gets compiled to (uint8_t)(c - '0') <= 9 on all decent compilers
8182}
@@ -104,7 +105,7 @@ is_not_structural_or_whitespace_or_exponent_or_decimal(unsigned char c) {
104105// check quickly whether the next 8 chars are made of digits
105106// at a glance, it looks better than Mula's
106107// http://0x80.pl/articles/swar-digits-validate.html
107- static inline bool is_made_of_eight_digits_fast (const char *chars) {
108+ really_inline bool is_made_of_eight_digits_fast (const char *chars) {
108109 uint64_t val;
109110 // this can read up to 7 bytes beyond the buffer size, but we require
110111 // SIMDJSON_PADDING of padding
@@ -123,7 +124,7 @@ static inline bool is_made_of_eight_digits_fast(const char *chars) {
123124//
124125// This function computes base * 10 ^ (- negative_exponent ).
125126// It is only even going to be used when negative_exponent is tiny.
126- static double subnormal_power10 (double base, int64_t negative_exponent) {
127+ really_inline double subnormal_power10 (double base, int64_t negative_exponent) {
127128 // avoid integer overflows in the pow expression, those values would
128129 // become zero anyway.
129130 if (negative_exponent < -1000 ) {
@@ -144,8 +145,8 @@ static double subnormal_power10(double base, int64_t negative_exponent) {
144145//
145146// Note: a redesign could avoid this function entirely.
146147//
147- static never_inline bool parse_float (const uint8_t *const buf, ParsedJson &pj,
148- const uint32_t offset, bool found_minus) {
148+ never_inline bool parse_float (const uint8_t *const buf, ParsedJson &pj,
149+ const uint32_t offset, bool found_minus) {
149150 const char *p = reinterpret_cast <const char *>(buf + offset);
150151 bool negative = false ;
151152 if (found_minus) {
@@ -268,7 +269,7 @@ static never_inline bool parse_float(const uint8_t *const buf, ParsedJson &pj,
268269 return false ;
269270 }
270271 double d = negative ? -i : i;
271- pj.write_tape_double (d);
272+ pj.on_number_double (d);
272273#ifdef JSON_TEST_NUMBERS // for unit testing
273274 found_float (d, buf + offset);
274275#endif
@@ -283,7 +284,7 @@ static never_inline bool parse_float(const uint8_t *const buf, ParsedJson &pj,
283284//
284285// This function will almost never be called!!!
285286//
286- static never_inline bool parse_large_integer (const uint8_t *const buf,
287+ never_inline bool parse_large_integer (const uint8_t *const buf,
287288 ParsedJson &pj,
288289 const uint32_t offset,
289290 bool found_minus) {
@@ -333,14 +334,14 @@ static never_inline bool parse_large_integer(const uint8_t *const buf,
333334 // as a positive signed integer, but the negative version is
334335 // possible.
335336 constexpr int64_t signed_answer = INT64_MIN;
336- pj.write_tape_s64 (signed_answer);
337+ pj.on_number_s64 (signed_answer);
337338#ifdef JSON_TEST_NUMBERS // for unit testing
338339 found_integer (signed_answer, buf + offset);
339340#endif
340341 } else {
341342 // we can negate safely
342343 int64_t signed_answer = -static_cast <int64_t >(i);
343- pj.write_tape_s64 (signed_answer);
344+ pj.on_number_s64 (signed_answer);
344345#ifdef JSON_TEST_NUMBERS // for unit testing
345346 found_integer (signed_answer, buf + offset);
346347#endif
@@ -353,12 +354,12 @@ static never_inline bool parse_large_integer(const uint8_t *const buf,
353354#ifdef JSON_TEST_NUMBERS // for unit testing
354355 found_integer (i, buf + offset);
355356#endif
356- pj.write_tape_s64 (i);
357+ pj.on_number_s64 (i);
357358 } else {
358359#ifdef JSON_TEST_NUMBERS // for unit testing
359360 found_unsigned_integer (i, buf + offset);
360361#endif
361- pj.write_tape_u64 (i);
362+ pj.on_number_u64 (i);
362363 }
363364 }
364365 return is_structural_or_whitespace (*p);
@@ -373,12 +374,13 @@ static never_inline bool parse_large_integer(const uint8_t *const buf,
373374// content and append a space before calling this function.
374375//
375376// Our objective is accurate parsing (ULP of 0 or 1) at high speed.
376- static really_inline bool parse_number (const uint8_t *const buf, ParsedJson &pj,
377- const uint32_t offset,
378- bool found_minus) {
377+ really_inline bool parse_number (const uint8_t *const buf,
378+ const uint32_t offset,
379+ bool found_minus,
380+ ParsedJson &pj) {
379381#ifdef SIMDJSON_SKIPNUMBERPARSING // for performance analysis, it is sometimes
380382 // useful to skip parsing
381- pj.write_tape_s64 (0 ); // always write zero
383+ pj.on_number_s64 (0 ); // always write zero
382384 return true ; // always succeeds
383385#else
384386 const char *p = reinterpret_cast <const char *>(buf + offset);
@@ -535,7 +537,7 @@ static really_inline bool parse_number(const uint8_t *const buf, ParsedJson &pj,
535537 double factor = power_of_ten[power_index];
536538 factor = negative ? -factor : factor;
537539 double d = i * factor;
538- pj.write_tape_double (d);
540+ pj.on_number_double (d);
539541#ifdef JSON_TEST_NUMBERS // for unit testing
540542 found_float (d, buf + offset);
541543#endif
@@ -546,7 +548,7 @@ static really_inline bool parse_number(const uint8_t *const buf, ParsedJson &pj,
546548 return parse_large_integer (buf, pj, offset, found_minus);
547549 }
548550 i = negative ? 0 - i : i;
549- pj.write_tape_s64 (i);
551+ pj.on_number_s64 (i);
550552#ifdef JSON_TEST_NUMBERS // for unit testing
551553 found_integer (i, buf + offset);
552554#endif
@@ -555,3 +557,4 @@ static really_inline bool parse_number(const uint8_t *const buf, ParsedJson &pj,
555557#endif // SIMDJSON_SKIPNUMBERPARSING
556558}
557559
560+ } // namespace numberparsing
0 commit comments