|
5 | 5 | #include <cctype>
|
6 | 6 | #include <cstdint>
|
7 | 7 | #include <cstring>
|
| 8 | +#include <iterator> |
8 | 9 |
|
9 | 10 | #include "float_common.h"
|
10 | 11 |
|
@@ -115,10 +116,10 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
|
115 | 116 | if ((p != pend) && (*p == decimal_point)) {
|
116 | 117 | ++p;
|
117 | 118 | // Fast approach only tested under little endian systems
|
118 |
| - if ((p + 8 <= pend) && is_made_of_eight_digits_fast(p)) { |
| 119 | + if ((std::distance(p, pend) >= 8) && is_made_of_eight_digits_fast(p)) { |
119 | 120 | i = i * 100000000 + parse_eight_digits_unrolled(p); // in rare cases, this will overflow, but that's ok
|
120 | 121 | p += 8;
|
121 |
| - if ((p + 8 <= pend) && is_made_of_eight_digits_fast(p)) { |
| 122 | + if ((std::distance(p, pend) >= 8) && is_made_of_eight_digits_fast(p)) { |
122 | 123 | i = i * 100000000 + parse_eight_digits_unrolled(p); // in rare cases, this will overflow, but that's ok
|
123 | 124 | p += 8;
|
124 | 125 | }
|
@@ -254,7 +255,7 @@ fastfloat_really_inline decimal parse_decimal(const char *p, const char *pend, p
|
254 | 255 | }
|
255 | 256 | // We expect that this loop will often take the bulk of the running time
|
256 | 257 | // because when a value has lots of digits, these digits often
|
257 |
| - while ((p + 8 <= pend) && (answer.num_digits + 8 < max_digits)) { |
| 258 | + while ((std::distance(p, pend) >= 8) && (answer.num_digits + 8 < max_digits)) { |
258 | 259 | uint64_t val = read_u64(p);
|
259 | 260 | if(! is_made_of_eight_digits_fast(val)) { break; }
|
260 | 261 | // We have eight digits, process them in one go!
|
|
0 commit comments