Skip to content

Commit 9c2ce52

Browse files
committed
Optimize estimating JSON string length.
1 parent e496fad commit 9c2ce52

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

json_parser.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,16 @@ static int __json_string_length(const char *cursor)
5858

5959
while (*cursor != '\"')
6060
{
61-
if ((unsigned char)*cursor < ' ')
62-
return -2;
63-
64-
cursor++;
65-
if (cursor[-1] == '\\')
61+
if (*cursor == '\\')
6662
{
63+
cursor++;
6764
if (*cursor == '\0')
6865
return -2;
69-
70-
cursor++;
7166
}
67+
else if ((unsigned char)*cursor < ' ')
68+
return -2;
7269

70+
cursor++;
7371
len++;
7472
}
7573

0 commit comments

Comments
 (0)