json_tokener: optimize parsing of integer values

speedup for 32-bit: ~8%
speedup for 64-bit: ~9%
This commit is contained in:
Ramiro Polla
2018-12-21 00:30:21 +01:00
parent d98fc501fb
commit c9a0ac5886
3 changed files with 42 additions and 13 deletions
+1 -1
View File
@@ -824,7 +824,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
{
int64_t num64;
double numd;
if (!tok->is_double && json_parse_int64(tok->pb->buf, &num64) == 0) {
if (!tok->is_double && json_parse_sanitized_int64(tok->pb->buf, tok->pb->bpos, &num64) == 0) {
if (num64 && tok->pb->buf[0]=='0' &&
(tok->flags & JSON_TOKENER_STRICT)) {
/* in strict mode, number must not start with 0 */