Software /
code /
prosody
Comparison
util/serialization.lua @ 10060:7a36b7ac309b 0.11
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 08 Jul 2019 02:46:27 +0200 |
parent | 9570:ce403b6470f8 |
child | 10061:5c71693c8345 |
comparison
equal
deleted
inserted
replaced
10059:c8c3f2eba898 | 10060:7a36b7ac309b |
---|---|
270 local success, ret = pcall(f); | 270 local success, ret = pcall(f); |
271 if not success then return nil, ret; end | 271 if not success then return nil, ret; end |
272 return ret; | 272 return ret; |
273 end | 273 end |
274 | 274 |
275 local default = new(); | |
275 return { | 276 return { |
276 new = new; | 277 new = new; |
277 serialize = function (x, opt) | 278 serialize = function (x, opt) |
278 return new(opt)(x); | 279 if opt == nil then |
280 return default(x); | |
281 else | |
282 return new(opt)(x); | |
283 end | |
279 end; | 284 end; |
280 deserialize = deserialize; | 285 deserialize = deserialize; |
281 }; | 286 }; |