diff --git a/util/util.lua b/util/util.lua index e611b5c..1b01f6a 100644 --- a/util/util.lua +++ b/util/util.lua @@ -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,