diff options
author | Kim Alvefur <zash@zash.se> | 2019-07-08 02:46:27 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-07-08 02:46:27 +0200 |
commit | 5399b9b9057f8202ceb25e933d10e1825383bc99 (patch) | |
tree | ed7768f531d3923c9d6169e0d1fceafe67638fb1 | |
parent | dd837c451e8a09051fb042d7eded02a124dfb75e (diff) | |
download | prosody-5399b9b9057f8202ceb25e933d10e1825383bc99.tar.gz prosody-5399b9b9057f8202ceb25e933d10e1825383bc99.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.
-rw-r--r-- | util/serialization.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/util/serialization.lua b/util/serialization.lua index dd6a2a2b..5121a9f9 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; }; |