mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 01:03:46 +01:00
Minor cleanup
This commit is contained in:
parent
0ae7c97e40
commit
83c20cf89d
16
table.lua
16
table.lua
@ -301,15 +301,10 @@ function shallowcopy(table)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function deepcopy_noncircular(table)
|
function deepcopy_noncircular(table)
|
||||||
local function _copy(value)
|
if type(table) ~= "table" then return table end
|
||||||
if type(value) == "table" then
|
|
||||||
return deepcopy_noncircular(value)
|
|
||||||
end
|
|
||||||
return value
|
|
||||||
end
|
|
||||||
local copy = {}
|
local copy = {}
|
||||||
for key, value in pairs(table) do
|
for key, value in pairs(table) do
|
||||||
copy[_copy(key)] = _copy(value)
|
copy[deepcopy_noncircular(key)] = deepcopy_noncircular(value)
|
||||||
end
|
end
|
||||||
return copy
|
return copy
|
||||||
end
|
end
|
||||||
@ -317,10 +312,11 @@ end
|
|||||||
function deepcopy(table)
|
function deepcopy(table)
|
||||||
local copies = {}
|
local copies = {}
|
||||||
local function _deepcopy(table)
|
local function _deepcopy(table)
|
||||||
if copies[table] then
|
local copy = copies[table]
|
||||||
return copies[table]
|
if copy then
|
||||||
|
return copy
|
||||||
end
|
end
|
||||||
local copy = {}
|
copy = {}
|
||||||
copies[table] = copy
|
copies[table] = copy
|
||||||
local function _copy(value)
|
local function _copy(value)
|
||||||
if type(value) == "table" then
|
if type(value) == "table" then
|
||||||
|
Loading…
Reference in New Issue
Block a user