aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-07-08 02:46:27 +0200
committerKim Alvefur <zash@zash.se>2019-07-08 02:46:27 +0200
commite081fd664251a2eb7ab68262c2b8a3cad4b381c7 (patch)
treeed7768f531d3923c9d6169e0d1fceafe67638fb1 /util
parentnet.server_epoll: Backport timer optimization 6c2370f17027 from trunk (see #1388) (diff)
downloadprosody-e081fd664251a2eb7ab68262c2b8a3cad4b381c7.tar.xz
prosody-e081fd664251a2eb7ab68262c2b8a3cad4b381c7.zip
util.serialization: Cache default serialization instance (fixes #1389)
Most serialization uses still use the default serialize() and thus duplicate much of the setup, which negates some of the performance improvements of the rewrite.
Diffstat (limited to 'util')
-rw-r--r--util/serialization.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/util/serialization.lua b/util/serialization.lua
index dd6a2a2b9..5121a9f9e 100644
--- a/util/serialization.lua
+++ b/util/serialization.lua
@@ -272,10 +272,15 @@ local function deserialize(str)
return ret;
end
+local default = new();
return {
new = new;
serialize = function (x, opt)
- return new(opt)(x);
+ if opt == nil then
+ return default(x);
+ else
+ return new(opt)(x);
+ end
end;
deserialize = deserialize;
};