mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
Optimize estimating JSON string length.
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user