View Single Post
06/18/14, 09:09 AM   #4
Wobin
 
Wobin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 78
I used the following in GuildLib

lua Code:
  1. local visitedTables = {}
  2.  
  3. function LibGuildInfo:DeepTableCopy(source, subCall)
  4.     local dest =  {}
  5.    
  6.     for k, v in pairs(source) do
  7.         if type(v) == "table" and not visitedTables[v] then                    
  8.             visitedTables[v] = true
  9.             dest[k] = self:DeepTableCopy(v, true)            
  10.         else
  11.             dest[k] = v
  12.         end
  13.     end
  14.    
  15.     if not subCall then visitedTables = {} end
  16.  
  17.     return dest
  18. end

It kept a list of table references in the external local, and just copied the reference if it had already been traversed.
  Reply With Quote