From 88c62cc7f616cf95e4e5ff1035929b857e573ecc Mon Sep 17 00:00:00 2001 From: Dmitry Arkhipov Date: Sat, 30 Sep 2023 14:30:36 +0300 Subject: [PATCH] temp --- include/boost/json/detail/sse2.hpp | 33 ++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/include/boost/json/detail/sse2.hpp b/include/boost/json/detail/sse2.hpp index da660274b..c334b5bae 100644 --- a/include/boost/json/detail/sse2.hpp +++ b/include/boost/json/detail/sse2.hpp @@ -315,17 +315,34 @@ inline int count_digits( char const* p ) noexcept inline uint64_t parse_unsigned( uint64_t r, char const * p, std::size_t n ) noexcept { - constexpr int N = 4; - auto const e = p + n; - for( ; (e - p) >= N; p += N ) + while( n >= 4 ) { - for( auto i = 0; i < N; ++i ) - r = r * 10 + p[i] - '0'; - } + r = r * 10 + p[0] - '0'; + r = r * 10 + p[1] - '0'; + r = r * 10 + p[2] - '0'; + r = r * 10 + p[3] - '0'; - for( ; p != e; ++p ) - r = r * 10 + *p - '0'; + p += 4; + n -= 4; + } + switch( n ) + { + case 0: + break; + case 1: + r = r * 10 + p[0] - '0'; + break; + case 2: + r = r * 10 + p[0] - '0'; + r = r * 10 + p[1] - '0'; + break; + case 3: + r = r * 10 + p[0] - '0'; + r = r * 10 + p[1] - '0'; + r = r * 10 + p[2] - '0'; + break; + } return r; }