From 83c20cf89dc1ab0618a98576bb31fc028558aa77 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Tue, 6 Sep 2022 15:04:25 +0200 Subject: [PATCH] Minor cleanup --- table.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/table.lua b/table.lua index 7fcc420..2850bc4 100644 --- a/table.lua +++ b/table.lua @@ -301,15 +301,10 @@ function shallowcopy(table) end function deepcopy_noncircular(table) - local function _copy(value) - if type(value) == "table" then - return deepcopy_noncircular(value) - end - return value - end + if type(table) ~= "table" then return table end local copy = {} for key, value in pairs(table) do - copy[_copy(key)] = _copy(value) + copy[deepcopy_noncircular(key)] = deepcopy_noncircular(value) end return copy end @@ -317,10 +312,11 @@ end function deepcopy(table) local copies = {} local function _deepcopy(table) - if copies[table] then - return copies[table] + local copy = copies[table] + if copy then + return copy end - local copy = {} + copy = {} copies[table] = copy local function _copy(value) if type(value) == "table" then