|
From a quick first glance, you're doing an unnecessary extra table
index (a relatively expensive operation) in your clone function -
clone = function(aTable) local newTable = {} for _,v in pairs(aTable) do newTable[_] = aTable[_]
...you've already got the value of v, you don't need to index aTable again.