Optimize estimating JSON string length.

This commit is contained in:
Xie Han
2024-01-30 23:06:03 +08:00
parent c617db227f
commit ae1bb27dda
+7 -9
View File
@@ -76,18 +76,16 @@ static int __json_string_length(const char *cursor)
while (*cursor != '\"')
{
if ((unsigned char)*cursor < ' ')
if (*cursor == '\\')
{
cursor++;
if (*cursor == '\0')
return -2;
}
else if ((unsigned char)*cursor < 0x20)
return -2;
cursor++;
if (cursor[-1] == '\\')
{
if (*cursor == '\0')
return -2;
cursor++;
}
len++;
}