aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-10-12 00:13:24 +0200
committerKim Alvefur <zash@zash.se>2018-10-12 00:13:24 +0200
commite0a16c75dcd3416e1f87b79aac5af5c461e05a23 (patch)
tree4f5e21721be10dfd4d8f4737a132ed6ddf0dcf28 /util
parent8d941e5d0f4865f61a490a39e9abb7ff95ecdfe8 (diff)
downloadprosody-e0a16c75dcd3416e1f87b79aac5af5c461e05a23.tar.gz
prosody-e0a16c75dcd3416e1f87b79aac5af5c461e05a23.zip
util.serialization: Simpler metatable pre-processing
It was too difficult to describe what it did.
Diffstat (limited to 'util')
-rw-r--r--util/serialization.lua26
1 files changed, 12 insertions, 14 deletions
diff --git a/util/serialization.lua b/util/serialization.lua
index f7f129b2..852b41da 100644
--- a/util/serialization.lua
+++ b/util/serialization.lua
@@ -139,25 +139,23 @@ local function new(opt)
end
o[t] = true;
- if freeze then
+
+ if freeze == true then
-- opportunity to do pre-serialization
local mt = getmetatable(t);
- local fr = (type(freeze) == "table" and freeze[mt]);
- local mf = mt and mt.__freeze;
- local tag;
- if type(fr) == "string" then
- tag = fr;
- fr = mf;
- elseif mt then
- tag = mt.__type;
- end
- if type(fr) == "function" then
- t = fr(t);
- if type(tag) == "string" then
- o[l], l = tag, l + 1;
+ if type(mt) == "table" then
+ local tag = mt.__name;
+ local fr = mt.__freeze;
+
+ if type(fr) == "function" then
+ t = fr(t);
+ if type(tag) == "string" then
+ o[l], l = tag, l + 1;
+ end
end
end
end
+
o[l], l = tstart, l + 1;
local indent = s_rep(indentwith, d);
local numkey = 1;