Minor optimization by replacing custom clearTable() function with wipe()

This commit is contained in:
Xinhuan
2008-10-30 03:43:39 +08:00
parent 3f3d02217f
commit b05e63e6f9
+3 -16
View File
@@ -50,8 +50,7 @@ LSM:Register("sound", "Aoogah!", [[Interface\AddOns\Omen\aoogah.ogg]])
-----------------------------------------------------------------------------
-- Localize some global functions
local floor, format = floor, format
local sort = sort
local tinsert, tremove = tinsert, tremove
local tinsert, tremove, sort, wipe = tinsert, tremove, sort, wipe
local UnitDetailedThreatSituation = UnitDetailedThreatSituation
local UnitExists, UnitGUID, UnitName, UnitClass = UnitExists, UnitGUID, UnitName, UnitClass
local UnitIsPlayer, UnitPlayerControlled, UnitCanAttack = UnitIsPlayer, UnitPlayerControlled, UnitCanAttack
@@ -229,18 +228,6 @@ local function delTable(t)
return nil -- return nil to assign input reference
end
-- Empties a table of everything -- Non-recursive
local function clearTable(t)
if type(t) == "table" then
for k, v in pairs(t) do
t[k] = nil
end
t[true] = true
t[true] = nil
setmetatable(t, nil)
end
end
-----------------------------------------------------------------------------
-- Omen initialization and frame functions
@@ -1395,7 +1382,7 @@ function Omen:UpdateBars()
if lastWarn.mobGUID ~= mobGUID then
delTable(threatStore)
threatStore = newTable()
clearTable(threatStoreTime)
wipe(threatStoreTime)
end
tinsert(threatStore, threatTable)
tinsert(threatStoreTime, GetTime())
@@ -1424,7 +1411,7 @@ function Omen:ClearAll()
-- Remove TPS data
delTable(threatStore)
threatStore = newTable()
clearTable(threatStoreTime)
wipe(threatStoreTime)
threatTable = nil
end