I used the following in GuildLib
lua Code:
local visitedTables = {}
function LibGuildInfo:DeepTableCopy(source, subCall)
local dest = {}
for k, v in pairs(source) do
if type(v) == "table" and not visitedTables[v] then
visitedTables[v] = true
dest[k] = self:DeepTableCopy(v, true)
else
dest[k] = v
end
end
if not subCall then visitedTables = {} end
return dest
end
It kept a list of table references in the external local, and just copied the reference if it had already been traversed.