simdjson  3.1.8
Ridiculously Fast JSON
numberparsing.h
1 #ifndef SIMDJSON_FALLBACK_NUMBERPARSING_H
2 #define SIMDJSON_FALLBACK_NUMBERPARSING_H
3 
4 #ifdef JSON_TEST_NUMBERS // for unit testing
5 void found_invalid_number(const uint8_t *buf);
6 void found_integer(int64_t result, const uint8_t *buf);
7 void found_unsigned_integer(uint64_t result, const uint8_t *buf);
8 void found_float(double result, const uint8_t *buf);
9 #endif
10 
11 namespace simdjson {
12 namespace SIMDJSON_IMPLEMENTATION {
13 namespace {
14 // credit: https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
15 static simdjson_inline uint32_t parse_eight_digits_unrolled(const char *chars) {
16  uint64_t val;
17  memcpy(&val, chars, sizeof(uint64_t));
18  val = (val & 0x0F0F0F0F0F0F0F0F) * 2561 >> 8;
19  val = (val & 0x00FF00FF00FF00FF) * 6553601 >> 16;
20  return uint32_t((val & 0x0000FFFF0000FFFF) * 42949672960001 >> 32);
21 }
22 static simdjson_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars) {
23  return parse_eight_digits_unrolled(reinterpret_cast<const char *>(chars));
24 }
25 
26 } // unnamed namespace
27 } // namespace SIMDJSON_IMPLEMENTATION
28 } // namespace simdjson
29 
30 #define SIMDJSON_SWAR_NUMBER_PARSING 1
31 
32 #include "simdjson/generic/numberparsing.h"
33 
34 #endif // SIMDJSON_FALLBACK_NUMBERPARSING_H
We want to support argument-dependent lookup (ADL).