22 namespace json_details {
23 inline constexpr auto is_digit =
25 return static_cast<unsigned>(
static_cast<unsigned char>( c ) ) -
26 static_cast<unsigned>(
27 static_cast<unsigned char>(
'0' ) ) <
30 : daw::UInt8{ 0xFFU };
33 template<
typename Predicate>
34 DAW_ATTRIB_FLATINLINE DAW_ATTRIB_NONNULL( )
constexpr std::int32_t
35 count_4digits( daw::not_null<char const *> first, Predicate pred ) {
36 daw::simple_array<daw::UInt8, 4>
const buff{ pred( first[3] ),
40 auto const v = DAW_BIT_CAST( std::uint32_t, buff );
42 auto result = daw::cxmath::count_leading_zeroes( v );
44 return static_cast<std::int32_t
>( result );
49 template<
typename Predicate>
50 DAW_ATTRIB_FLATINLINE DAW_ATTRIB_NONNULL( )
constexpr std::int32_t
51 count_8digits( daw::not_null<char const *> first, Predicate pred ) {
52 daw::simple_array<daw::UInt8, 8>
const buff{ pred( first[7] ),
61 auto const v = DAW_BIT_CAST( std::uint64_t, buff );
63 auto result = daw::cxmath::count_leading_zeroes( v );
65 return static_cast<std::int32_t
>( result );
71 constexpr daw::not_null<char const *>
72 count_digits( daw::not_null<char const *> first,
73 daw::not_null<char const *> last ) {
74 while( DAW_LIKELY( last - first >= 8 ) ) {
75 auto const v = count_8digits( first, is_digit );
81 while( last - first >= 4 ) {
82 auto const v = count_4digits( first, is_digit );
89 while( first != last ) {
90 if(
static_cast<unsigned>( *first ) -
91 static_cast<unsigned>(
static_cast<unsigned char>(
'0' ) ) >=