function xdecor.maxn(T)
local n = 0
for k in pairs(T) do
- if k > n then n = k end
+ if k > n then
+ n = k
+ end
end
+
return n
end
-- Returns the length of an hash table.
function xdecor.tablelen(T)
local n = 0
- for _ in pairs(T) do n = n + 1 end
+
+ for _ in pairs(T) do
+ n = n + 1
+ end
+
return n
end
-- Deep copy of a table. Borrowed from mesecons mod (https://github.com/Jeija/minetest-mod-mesecons).
function xdecor.tablecopy(T)
- if type(T) ~= "table" then return T end -- No need to copy.
+ if type(T) ~= "table" then
+ return T -- No need to copy.
+ end
+
local new = {}
for k, v in pairs(T) do
new[k] = v
end
end
+
return new
end