Created
March 15, 2020 02:15
-
-
Save vinniefalco/b8d44c57ebbe87ba6405304c32ce3cce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size_t | |
number_parser:: | |
parse( | |
number& result, | |
char const* begin, | |
char const* end, | |
error_code& ec) | |
{ | |
char_stream cs(begin, end); | |
bool neg; | |
uint64_t m64; | |
int sig; | |
neg = consume(cs, '-'); | |
if(cs.peek() == '0') | |
{ | |
m64 = 0; | |
} | |
else if(BOOST_JSON_LIKELY( | |
cs.peek() >= '1' && | |
cs.peek() <= '9')) | |
{ | |
m64 = static_cast<uint64_t>( | |
cs.get() - '0'); | |
if(neg) | |
{ | |
while( | |
cs.peek() >= '0' && | |
cs.peek() <= '9') | |
{ | |
} | |
} | |
else | |
{ | |
while( | |
cs.peek() >= '0' && | |
cs.peek() <= '9') | |
{ | |
if(BOOST_JSON_UNLIKELY( | |
// 18446744073709551615 UINT64_MAX | |
m64 >= 1844674407370955161)) | |
{ | |
if(BOOST_JSON_LIKELY( | |
m64 != 1844674407370955161) || | |
cs.peek() == '5') | |
{ | |
// use double | |
break; | |
} | |
} | |
m64 = m64 * 10 + static_cast< | |
unsigned int>(cs.get() - '0'); | |
} | |
} | |
} | |
else | |
{ | |
return 0; | |
} | |
return p - begin; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment