@mydevelopers
You know the famous table_print function. I simply modified it to count number of top level tables and all value objects.
Final results for _G:
tableCount: 167
valueCount: 1306
As a side note: I also counted recursion depth of your dump function. It throws a stack overflow exception when recursion depth is 61.
[code]
tableCount = 0
valueCount = 0
local tCount, vCount = table_print(_G)
function table_print (tt, indent, done)
done = done or {}
indent = indent or 0
if type(tt) == “table” then
tableCount = tableCount + 1
for key, value in pairs (tt) do
io.write(string.rep (" “, indent)) – indent it
if type (value) == “table” and not done [value] then
done [value] = true
io.write(string.format(”[%s] => table\n", tostring (key)));
io.write(string.rep (" “, indent+4)) – indent it
io.write(”(\n");
table_print (value, indent + 7, done)
io.write(string.rep (" “, indent+4)) – indent it
io.write(”)\n");
else
valueCount = valueCount + 1
io.write(string.format("[%s] => %s\n",
tostring (key), tostring(value)))
end
end
else
io.write(tt … “\n”)
end
return tableCount, valueCount
end
[/code] [import]uid: 11686 topic_id: 23072 reply_id: 98960[/import]