Optimize estimating JSON string length.

This commit is contained in:
Xie Han
2024-01-30 23:04:39 +08:00
parent 773aef1f40
commit c66f85392c

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++;
}