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.
--- 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;
};