mirror of
https://github.com/nlohmann/json.git
synced 2026-09-29 19:20:30 +00:00
Read whole blocks of eight digits of json_view directly
A block of eight digits of a number token lies inside the input (the digits were counted while scanning, or are recorded in the digit layout), so parse_upto19() reads it without the bounds check of the last, partial block. Traversing canada.json: -11% instructions, -6% cycles. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -175,7 +175,8 @@ NLOHMANN_VIEW_ALWAYS_INLINE std::uint64_t parse_upto19(const unsigned char* p, u
|
||||
std::uint64_t w = 0;
|
||||
while (k >= 8)
|
||||
{
|
||||
w = (w * 100000000u) + parse_upto8(p, 8, limit);
|
||||
// (eight digits of the token: they lie below limit)
|
||||
w = (w * 100000000u) + parse_eight_digits(read_eight_bytes(p));
|
||||
p += 8;
|
||||
k -= 8;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user