From d3f86d02755f7209eebc8616560de04629940672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Fri, 11 Jul 2025 15:11:55 +0200 Subject: [PATCH] util: clean table copy --- util/util.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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,