mirror of
https://github.com/Reuh/ubiquitousse.git
synced 2025-10-27 17:19:31 +00:00
util: clean table copy
This commit is contained in:
parent
6cf0fa4053
commit
d3f86d0275
1 changed files with 2 additions and 5 deletions
|
|
@ -189,14 +189,11 @@ util = {
|
|||
-- @treturn table the copied table
|
||||
copy = function(t, cache)
|
||||
if cache == nil then cache = {} end
|
||||
if cache[t] then return cache[t] end
|
||||
local r = {}
|
||||
cache[t] = r
|
||||
for k, v in pairs(t) do
|
||||
if type(v) == "table" then
|
||||
r[k] = cache[v] or util.copy(v, cache)
|
||||
else
|
||||
r[k] = v
|
||||
end
|
||||
r[k] = type(v) == "table" and util.copy(v, cache) or v
|
||||
end
|
||||
return setmetatable(r, getmetatable(t))
|
||||
end,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue