refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-11-05 07:22:45 +01:00
parent 80ec35bca1
commit 98f5aacacd
4 changed files with 10 additions and 17 deletions
+4 -14
View File
@@ -4,7 +4,7 @@ local next, getn, setn, tremove, type, setmetatable = next, getn, table.setn, tr
local wipe, acquire, release, set_auto_release
do
local pool, pool_size, overflow_pool, auto_release = {}, 0, setmetatable({}, { __mode='k' }), {}
local pool, pool_size, overflow_pool, auto_release = {}, 0, setmetatable({}, {__mode='k'}), {}
function wipe(t)
setmetatable(t, nil)
@@ -31,6 +31,7 @@ do
end
return {}
end
M.acquire = acquire
function release(t)
wipe(t)
@@ -72,17 +73,6 @@ M.perm = setmetatable({}, {
__sub = function(_, v) set_auto_release(v, false); return v end,
})
M.init = setmetatable({}, {
__metatable = false,
__newindex = function(_, t, init)
wipe(t)
for k, v in init do
t[k] = v
setn(t, getn(init))
end
end
})
do
local function ret(t)
if getn(t) > 0 then
@@ -94,7 +84,7 @@ do
M.ret = ret
end
M.empty = setmetatable({}, { __metatable=false, __newindex=nop })
M.empty = setmetatable({}, {__metatable=false, __newindex=nop})
local vararg
do
@@ -134,7 +124,7 @@ do
function vararg(f)
local chunk = loadstring(code)
setfenv(chunk, { f=f, setn=setn, acquire=acquire, set_auto_release=set_auto_release })
setfenv(chunk, {f=f, setn=setn, acquire=acquire, set_auto_release=set_auto_release})
return chunk()
end
M.vararg = setmetatable({}, {
+2 -1
View File
@@ -438,7 +438,8 @@ function update_inventory_records()
end
end
end
init[inventory_records] = temp-values(auctionable_map)
release(inventory_records)
inventory_records = values(auctionable_map)
sort(inventory_records, function(a, b) return a.name < b.name end)
refresh = true
end
+2 -1
View File
@@ -176,7 +176,8 @@ function clear_form()
UIDropDownMenu_ClearAll(quality_dropdown)
filter_parameter_input:ClearFocus()
wipe(post_filter)
init[filter_builder_state] = temp-T('selected', 0)
wipe(filter_builder_state)
filter_builder_state.selected = 0
update_filter_display()
end
+2 -1
View File
@@ -180,7 +180,8 @@ function start_real_time_scan(query, search, continuation)
for _, record in new_records do
map[record.sniping_signature] = record
end
init[new_records] = temp-values(map)
release(new_records)
new_records = values(map)
if getn(new_records) > 2000 then
StaticPopup_Show'AUX_SEARCH_TABLE_FULL'