forked from Gogo1951/GDKPd-Classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TempTables.lua
39 lines (36 loc) · 886 Bytes
/
TempTables.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local addontable = select(2,...)
local logTableRequests = false
local tables = {}
local meta = {
__index = {
Release=function(t,noRecursion)
if not noRecursion then
for key,val in pairs(t) do
if (type(val) == "table") and (getmetatable(val) == "TempTable") then
val:Release()
end
end
end
table.wipe(t)
if not tContains(tables,t) then
tinsert(tables,t)
end
end,
},
__metatable = "TempTable",
}
if logTableRequests then
TempTables_RequestLog = {}
end
function addontable.emptytable(...)
local t = tremove(tables) or setmetatable({},meta)
for i=1,select('#',...) do
t[i] = (select(i,...))
end
if logTableRequests then
local tostrT = tostring(t)
TempTables_RequestLog[tostrT] = TempTables_RequestLog[tostrT] or {}
tinsert(TempTables_RequestLog[tostrT],debugstack())
end
return t
end