Remove the eight-digit case of the view's digit parser

Since whole blocks of eight digits are read directly, parse_upto8() only
gets fewer than eight digits; its eight-digit case was dead code.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-29 09:52:19 +02:00
parent 58ac756134
commit a49d6e2e3b
+3 -6
View File
@@ -147,16 +147,13 @@ inline std::uint64_t int_pow10(unsigned k) noexcept
return table[k]; return table[k];
} }
/// value of k <= 8 digits at p in one step if [p, p + 8) lies below limit, /// value of 0 < k < 8 digits at p in one step if [p, p + 8) lies below
/// else one digit at a time /// limit, else one digit at a time (whole blocks of eight digits are read by
/// parse_upto19() directly)
NLOHMANN_VIEW_ALWAYS_INLINE std::uint64_t parse_upto8(const unsigned char* p, unsigned k, const unsigned char* limit) noexcept NLOHMANN_VIEW_ALWAYS_INLINE std::uint64_t parse_upto8(const unsigned char* p, unsigned k, const unsigned char* limit) noexcept
{ {
if (NLOHMANN_VIEW_LIKELY(limit - p >= 8)) if (NLOHMANN_VIEW_LIKELY(limit - p >= 8))
{ {
if (k == 8)
{
return parse_eight_digits(read_eight_bytes(p));
}
// move the k digits to the top and pad the vacated low bytes with '0' // move the k digits to the top and pad the vacated low bytes with '0'
const unsigned shift = 8 * (8 - k); const unsigned shift = 8 * (8 - k);
return parse_eight_digits((read_eight_bytes(p) << shift) | (0x3030303030303030u >> (8 * k))); return parse_eight_digits((read_eight_bytes(p) << shift) | (0x3030303030303030u >> (8 * k)));