@@ -45,7 +45,7 @@ fastfloat_really_inline constexpr uint64_t byteswap(uint64_t val) {
45
45
// Read 8 UC into a u64. Truncates UC if not char.
46
46
template <typename UC>
47
47
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint64_t
48
- read8_to_u64 (const UC *chars) {
48
+ read8_to_u64 (UC const *chars) {
49
49
if (cpp20_and_in_constexpr () || !std::is_same<UC, char >::value) {
50
50
uint64_t val = 0 ;
51
51
for (int i = 0 ; i < 8 ; ++i) {
@@ -65,9 +65,9 @@ read8_to_u64(const UC *chars) {
65
65
66
66
#ifdef FASTFLOAT_SSE2
67
67
68
- fastfloat_really_inline uint64_t simd_read8_to_u64 (const __m128i data) {
68
+ fastfloat_really_inline uint64_t simd_read8_to_u64 (__m128i const data) {
69
69
FASTFLOAT_SIMD_DISABLE_WARNINGS
70
- const __m128i packed = _mm_packus_epi16 (data, data);
70
+ __m128i const packed = _mm_packus_epi16 (data, data);
71
71
#ifdef FASTFLOAT_64BIT
72
72
return uint64_t (_mm_cvtsi128_si64 (packed));
73
73
#else
@@ -79,26 +79,26 @@ fastfloat_really_inline uint64_t simd_read8_to_u64(const __m128i data) {
79
79
FASTFLOAT_SIMD_RESTORE_WARNINGS
80
80
}
81
81
82
- fastfloat_really_inline uint64_t simd_read8_to_u64 (const char16_t *chars) {
82
+ fastfloat_really_inline uint64_t simd_read8_to_u64 (char16_t const *chars) {
83
83
FASTFLOAT_SIMD_DISABLE_WARNINGS
84
84
return simd_read8_to_u64 (
85
- _mm_loadu_si128 (reinterpret_cast <const __m128i *>(chars)));
85
+ _mm_loadu_si128 (reinterpret_cast <__m128i const *>(chars)));
86
86
FASTFLOAT_SIMD_RESTORE_WARNINGS
87
87
}
88
88
89
89
#elif defined(FASTFLOAT_NEON)
90
90
91
- fastfloat_really_inline uint64_t simd_read8_to_u64 (const uint16x8_t data) {
91
+ fastfloat_really_inline uint64_t simd_read8_to_u64 (uint16x8_t const data) {
92
92
FASTFLOAT_SIMD_DISABLE_WARNINGS
93
93
uint8x8_t utf8_packed = vmovn_u16 (data);
94
94
return vget_lane_u64 (vreinterpret_u64_u8 (utf8_packed), 0 );
95
95
FASTFLOAT_SIMD_RESTORE_WARNINGS
96
96
}
97
97
98
- fastfloat_really_inline uint64_t simd_read8_to_u64 (const char16_t *chars) {
98
+ fastfloat_really_inline uint64_t simd_read8_to_u64 (char16_t const *chars) {
99
99
FASTFLOAT_SIMD_DISABLE_WARNINGS
100
100
return simd_read8_to_u64 (
101
- vld1q_u16 (reinterpret_cast <const uint16_t *>(chars)));
101
+ vld1q_u16 (reinterpret_cast <uint16_t const *>(chars)));
102
102
FASTFLOAT_SIMD_RESTORE_WARNINGS
103
103
}
104
104
@@ -118,9 +118,9 @@ uint64_t simd_read8_to_u64(UC const *) {
118
118
// credit @aqrit
119
119
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint32_t
120
120
parse_eight_digits_unrolled (uint64_t val) {
121
- const uint64_t mask = 0x000000FF000000FF ;
122
- const uint64_t mul1 = 0x000F424000000064 ; // 100 + (1000000ULL << 32)
123
- const uint64_t mul2 = 0x0000271000000001 ; // 1 + (10000ULL << 32)
121
+ uint64_t const mask = 0x000000FF000000FF ;
122
+ uint64_t const mul1 = 0x000F424000000064 ; // 100 + (1000000ULL << 32)
123
+ uint64_t const mul2 = 0x0000271000000001 ; // 1 + (10000ULL << 32)
124
124
val -= 0x3030303030303030 ;
125
125
val = (val * 10 ) + (val >> 8 ); // val = (val * 2561) >> 8;
126
126
val = (((val & mask) * mul1) + (((val >> 16 ) & mask) * mul2)) >> 32 ;
@@ -150,20 +150,20 @@ is_made_of_eight_digits_fast(uint64_t val) noexcept {
150
150
// Using this style (instead of is_made_of_eight_digits_fast() then
151
151
// parse_eight_digits_unrolled()) ensures we don't load SIMD registers twice.
152
152
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 bool
153
- simd_parse_if_eight_digits_unrolled (const char16_t *chars,
153
+ simd_parse_if_eight_digits_unrolled (char16_t const *chars,
154
154
uint64_t &i) noexcept {
155
155
if (cpp20_and_in_constexpr ()) {
156
156
return false ;
157
157
}
158
158
#ifdef FASTFLOAT_SSE2
159
159
FASTFLOAT_SIMD_DISABLE_WARNINGS
160
- const __m128i data =
161
- _mm_loadu_si128 (reinterpret_cast <const __m128i *>(chars));
160
+ __m128i const data =
161
+ _mm_loadu_si128 (reinterpret_cast <__m128i const *>(chars));
162
162
163
163
// (x - '0') <= 9
164
164
// http://0x80.pl/articles/simd-parsing-int-sequences.html
165
- const __m128i t0 = _mm_add_epi16 (data, _mm_set1_epi16 (32720 ));
166
- const __m128i t1 = _mm_cmpgt_epi16 (t0, _mm_set1_epi16 (-32759 ));
165
+ __m128i const t0 = _mm_add_epi16 (data, _mm_set1_epi16 (32720 ));
166
+ __m128i const t1 = _mm_cmpgt_epi16 (t0, _mm_set1_epi16 (-32759 ));
167
167
168
168
if (_mm_movemask_epi8 (t1) == 0 ) {
169
169
i = i * 100000000 + parse_eight_digits_unrolled (simd_read8_to_u64 (data));
@@ -173,12 +173,12 @@ simd_parse_if_eight_digits_unrolled(const char16_t *chars,
173
173
FASTFLOAT_SIMD_RESTORE_WARNINGS
174
174
#elif defined(FASTFLOAT_NEON)
175
175
FASTFLOAT_SIMD_DISABLE_WARNINGS
176
- const uint16x8_t data = vld1q_u16 (reinterpret_cast <const uint16_t *>(chars));
176
+ uint16x8_t const data = vld1q_u16 (reinterpret_cast <uint16_t const *>(chars));
177
177
178
178
// (x - '0') <= 9
179
179
// http://0x80.pl/articles/simd-parsing-int-sequences.html
180
- const uint16x8_t t0 = vsubq_u16 (data, vmovq_n_u16 (' 0' ));
181
- const uint16x8_t mask = vcltq_u16 (t0, vmovq_n_u16 (' 9' - ' 0' + 1 ));
180
+ uint16x8_t const t0 = vsubq_u16 (data, vmovq_n_u16 (' 0' ));
181
+ uint16x8_t const mask = vcltq_u16 (t0, vmovq_n_u16 (' 9' - ' 0' + 1 ));
182
182
183
183
if (vminvq_u16 (mask) == 0xFFFF ) {
184
184
i = i * 100000000 + parse_eight_digits_unrolled (simd_read8_to_u64 (data));
@@ -208,7 +208,7 @@ bool simd_parse_if_eight_digits_unrolled(UC const *, uint64_t &) {
208
208
209
209
template <typename UC, FASTFLOAT_ENABLE_IF(!std::is_same<UC, char >::value) = 0 >
210
210
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void
211
- loop_parse_if_eight_digits (const UC *&p, const UC *const pend, uint64_t &i) {
211
+ loop_parse_if_eight_digits (UC const *&p, UC const *const pend, uint64_t &i) {
212
212
if (!has_simd_opt<UC>()) {
213
213
return ;
214
214
}
@@ -220,7 +220,7 @@ loop_parse_if_eight_digits(const UC *&p, const UC *const pend, uint64_t &i) {
220
220
}
221
221
222
222
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void
223
- loop_parse_if_eight_digits (const char *&p, const char *const pend,
223
+ loop_parse_if_eight_digits (char const *&p, char const *const pend,
224
224
uint64_t &i) {
225
225
// optimizes better than parse_if_eight_digits_unrolled() for UC = char.
226
226
while ((std::distance (p, pend) >= 8 ) &&
@@ -259,12 +259,12 @@ template <typename UC> struct parsed_number_string_t {
259
259
bool valid{false };
260
260
bool too_many_digits{false };
261
261
// contains the range of the significant digits
262
- span<const UC > integer{}; // non-nullable
263
- span<const UC > fraction{}; // nullable
262
+ span<UC const > integer{}; // non-nullable
263
+ span<UC const > fraction{}; // nullable
264
264
parse_error error{parse_error::no_error};
265
265
};
266
266
267
- using byte_span = span<const char >;
267
+ using byte_span = span<char const >;
268
268
using parsed_number_string = parsed_number_string_t <char >;
269
269
270
270
template <typename UC>
@@ -328,7 +328,7 @@ parse_number_string(UC const *p, UC const *pend,
328
328
}
329
329
UC const *const end_of_integer_part = p;
330
330
int64_t digit_count = int64_t (end_of_integer_part - start_digits);
331
- answer.integer = span<const UC >(start_digits, size_t (digit_count));
331
+ answer.integer = span<UC const >(start_digits, size_t (digit_count));
332
332
if (uint64_t (fmt & detail::basic_json_fmt)) {
333
333
// at least 1 digit in integer part, without leading zeros
334
334
if (digit_count == 0 ) {
@@ -341,7 +341,7 @@ parse_number_string(UC const *p, UC const *pend,
341
341
}
342
342
343
343
int64_t exponent = 0 ;
344
- const bool has_decimal_point = (p != pend) && (*p == decimal_point);
344
+ bool const has_decimal_point = (p != pend) && (*p == decimal_point);
345
345
if (has_decimal_point) {
346
346
++p;
347
347
UC const *before = p;
@@ -355,7 +355,7 @@ parse_number_string(UC const *p, UC const *pend,
355
355
i = i * 10 + digit; // in rare cases, this will overflow, but that's ok
356
356
}
357
357
exponent = before - p;
358
- answer.fraction = span<const UC >(before, size_t (p - before));
358
+ answer.fraction = span<UC const >(before, size_t (p - before));
359
359
digit_count -= exponent;
360
360
}
361
361
if (uint64_t (fmt & detail::basic_json_fmt)) {
@@ -446,7 +446,7 @@ parse_number_string(UC const *p, UC const *pend,
446
446
i = 0 ;
447
447
p = answer.integer .ptr ;
448
448
UC const *int_end = p + answer.integer .len ();
449
- const uint64_t minimal_nineteen_digit_integer{1000000000000000000 };
449
+ uint64_t const minimal_nineteen_digit_integer{1000000000000000000 };
450
450
while ((i < minimal_nineteen_digit_integer) && (p != int_end)) {
451
451
i = i * 10 + uint64_t (*p - UC (' 0' ));
452
452
++p;
@@ -498,7 +498,7 @@ parse_int_string(UC const *p, UC const *pend, T &value,
498
498
++p;
499
499
}
500
500
501
- const bool has_leading_zeros = p > start_num;
501
+ bool const has_leading_zeros = p > start_num;
502
502
503
503
UC const *const start_digits = p;
504
504
0 commit comments