aboutsummaryrefslogtreecommitdiffstats
path: root/util/json.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2013-05-05 15:02:33 -0400
committerWaqas Hussain <waqas20@gmail.com>2013-05-05 15:02:33 -0400
commitca64b965344a7d4039d3c9745e593aacd5281504 (patch)
tree417dc6da4013335fb024110062eb13f58ee0ed07 /util/json.lua
parent37094685f47c050702a6fc2f9cdd9b6b06dccd90 (diff)
downloadprosody-ca64b965344a7d4039d3c9745e593aacd5281504.tar.gz
prosody-ca64b965344a7d4039d3c9745e593aacd5281504.zip
util.json: Optimize long string parsing.
Diffstat (limited to 'util/json.lua')
-rw-r--r--util/json.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/util/json.lua b/util/json.lua
index 9c2dd2c6..6251af1a 100644
--- a/util/json.lua
+++ b/util/json.lua
@@ -258,16 +258,16 @@ function json.decode(json)
return val;
end
local function readstring()
- local s = "";
+ local s = {};
checkandskip("\"");
while ch do
while ch and ch ~= "\\" and ch ~= "\"" do
- s = s..ch; next();
+ t_insert(s, ch); next();
end
if ch == "\\" then
next();
if unescapes[ch] then
- s = s..unescapes[ch];
+ t_insert(s, unescapes[ch]);
next();
elseif ch == "u" then
local seq = "";
@@ -277,13 +277,13 @@ function json.decode(json)
if not ch:match("[0-9a-fA-F]") then error("invalid unicode escape sequence in string"); end
seq = seq..ch;
end
- s = s..codepoint_to_utf8(tonumber(seq, 16));
+ t_insert(s, codepoint_to_utf8(tonumber(seq, 16)));
next();
else error("invalid escape sequence in string"); end
end
if ch == "\"" then
next();
- return s;
+ return t_concat(s);
end
end
error("eof while reading string");