Skip to content

Commit 7ca7c39

Browse files
committed
Optimize parsing numbers.
1 parent e2947a7 commit 7ca7c39

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

json_parser.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,12 @@ static int __parse_json_number(const char *cursor, const char **end,
390390
if (*cursor == '-')
391391
cursor++;
392392

393-
if (!isdigit(*cursor))
394-
return -2;
395-
396-
if (*cursor == '0' && isdigit(cursor[1]))
393+
if (*cursor == '0')
394+
{
395+
if (isdigit(cursor[1]))
396+
return -2;
397+
}
398+
else if (!isdigit(*cursor))
397399
return -2;
398400

399401
cursor++;

0 commit comments

Comments
 (0)