mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 09:09:31 +00:00
Also copy keys when copying variables
This commit is contained in:
parent
95683a0ffd
commit
b50d783928
1 changed files with 3 additions and 3 deletions
|
|
@ -15,8 +15,8 @@ local function replace_in_table(t, to_replace, already_replaced)
|
||||||
end
|
end
|
||||||
|
|
||||||
common = {
|
common = {
|
||||||
--- recursively copy a table, handle cyclic references, no metatable, don't copy keys
|
--- recursively copy a table (key & values), handle cyclic references, no metatable
|
||||||
-- cache is table with copied tables [original table] = copied value, will use temporary table is omitted
|
-- cache is table with copied tables [original table] = copied value, will create temporary table if argument is omitted
|
||||||
copy = function(t, cache)
|
copy = function(t, cache)
|
||||||
if type(t) == "table" then
|
if type(t) == "table" then
|
||||||
cache = cache or {}
|
cache = cache or {}
|
||||||
|
|
@ -26,7 +26,7 @@ common = {
|
||||||
local c = {}
|
local c = {}
|
||||||
cache[t] = c
|
cache[t] = c
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
c[k] = common.copy(v, cache)
|
c[common.copy(k, cache)] = common.copy(v, cache)
|
||||||
end
|
end
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue