diff options
author | Hans Hagen <pragma@wxs.nl> | 2019-09-09 14:55:35 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2019-09-09 14:55:35 +0200 |
commit | 438b065a2337ee587442f25ddc587c4762f4d0b0 (patch) | |
tree | d18c8f7e51dd7e96b8e774f94d3f8862a6c38f73 /tex/context/base/mkiv/util-tab.lua | |
parent | fca2d946bc4d3ef525c3a2c9016e3b88d6d09812 (diff) | |
download | context-438b065a2337ee587442f25ddc587c4762f4d0b0.tar.gz |
2019-09-09 13:52:00
Diffstat (limited to 'tex/context/base/mkiv/util-tab.lua')
-rw-r--r-- | tex/context/base/mkiv/util-tab.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tex/context/base/mkiv/util-tab.lua b/tex/context/base/mkiv/util-tab.lua index f970d8ace..410292ca8 100644 --- a/tex/context/base/mkiv/util-tab.lua +++ b/tex/context/base/mkiv/util-tab.lua @@ -341,7 +341,21 @@ function table.fastserialize(t,prefix) -- todo, move local function out m = m + 1 r[m] = "{" if n > 0 then - for i=0,n do + local v = t[0] + if v then + local tv = type(v) + if tv == "string" then + m = m + 1 r[m] = f_indexed_string(0,v) + elseif tv == "number" then + m = m + 1 r[m] = f_indexed_number(0,v) + elseif tv == "table" then + m = m + 1 r[m] = f_indexed_table(0) + fastserialize(v) + elseif tv == "boolean" then + m = m + 1 r[m] = f_indexed_boolean(0,v) + end + end + for i=1,n do local v = t[i] local tv = type(v) if tv == "string" then @@ -355,6 +369,8 @@ function table.fastserialize(t,prefix) -- todo, move local function out end end end + -- hm, can't we avoid this ... lua should have a way to check if there + -- is a hash part for k, v in next, t do local tk = type(k) if tk == "number" then @@ -411,7 +427,7 @@ function table.deserialize(str) return code end --- inspect(table.fastserialize { a = 1, b = { 4, { 5, 6 } }, c = { d = 7, e = 'f"g\nh' } }) +-- inspect(table.fastserialize { a = 1, b = { [0]=4, { 5, 6 } }, c = { d = 7, e = 'f"g\nh' } }) function table.load(filename,loader) if filename then |