Is this the most efficient deep copy I can do? Or can someone suggest improvements? I haven’t tested it on much yet, but I have a requirement to deep copy some structures. Yes, it’s using recursion, but I’m doing it in the agent, there’s no risk of self-reference as the tables and arrays are decoded from JSON and it’s highly unlikely that it’ll deal with anything deeper than 5 levels.
`
function deepCopy(container){
switch(typeof(container)){
case "table":
local result = clone container;
foreach( k,v in container)
result[k] = deepCopy(v);
return result;
case "array":
return container.map(deepCopy);
default:
return container;
}
}`