# HG changeset patch # User Kim Alvefur # Date 1562546787 -7200 # Node ID 7a36b7ac309bbca74ad75edd9cf86db33535ba7d # Parent c8c3f2eba8981ad83dcae18f4e69ebee23498f32 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. diff -r c8c3f2eba898 -r 7a36b7ac309b util/serialization.lua --- a/util/serialization.lua Mon Jul 08 01:17:34 2019 +0200 +++ b/util/serialization.lua Mon Jul 08 02:46:27 2019 +0200 @@ -272,10 +272,15 @@ 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; };