From 2bb3c39865ea8911be45269efbef4e90913ca2d7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 26 Mar 2020 22:00:26 +0200 Subject: [PATCH] Fix parse_unsigned --- include/boost/json/detail/sse2.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/json/detail/sse2.hpp b/include/boost/json/detail/sse2.hpp index 63cfdc4e..1f4baf89 100644 --- a/include/boost/json/detail/sse2.hpp +++ b/include/boost/json/detail/sse2.hpp @@ -126,13 +126,13 @@ inline std::size_t count_digits( char const* p ) noexcept { std::size_t n = 0; - for( ; n < 16; ++n ) + for( ; n < 16; ++n ) { unsigned char const d = *p++ - '0'; if(d > 9) break; } - return n; + return n; } #endif @@ -144,6 +144,8 @@ inline uint64_t parse_unsigned( uint64_t r, char const * p, std::size_t n ) noex uint32_t v; memcpy( &v, p, 4 ); + v -= 0x30303030; + unsigned w0 = v & 0xFF; unsigned w1 = (v >> 8) & 0xFF; unsigned w2 = (v >> 16) & 0xFF;