Skip to content

Commit a169ebf

Browse files
committed
Optimize estimating JSON string length.
1 parent be3cbe4 commit a169ebf

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

json_parser.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,22 @@ static int __json_string_length(const char *cursor, size_t *len)
9292

9393
while (1)
9494
{
95-
if (__character_map[(unsigned char)*cursor])
95+
if (__character_map[(unsigned char)cursor[n]])
9696
{
97-
cursor++;
9897
n++;
9998
continue;
10099
}
101100

102-
if (*cursor == '\"')
101+
if (cursor[n] == '\"')
103102
break;
104103

105-
if (*cursor != '\\')
104+
if (cursor[n] != '\\')
106105
return -2;
107106

108107
cursor++;
109-
if (*cursor == '\0')
108+
if (cursor[n] == '\0')
110109
return -2;
111110

112-
cursor++;
113111
n++;
114112
}
115113

0 commit comments

Comments
 (0)