Refactor string scanning for better performance

pull/22/head
sfeuerstein-op 2020-03-17 10:54:47 +01:00 committed by GitHub
parent e1f3fdcd88
commit a6100d43d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -219,15 +219,13 @@ local function parse_string(str, i)
local s = {}
local j = i + 1
while j <= #str do
local x = str:byte(j)
local k = j
while not (x < 32 or x == 92 or x == 34) do
j = j + 1
x = str:byte(j)
local k, l = str:find("^[^%c\\\"]+", j)
if k then
table.insert(s, str:sub(k, l))
j = l + 1
end
table.insert(s, str:sub(k, j - 1))
local x = str:byte(j)
if x < 32 then
decode_error(str, j, "control character in string")