Save memory by not creating many small Lua tables per frame refresh.
Johnny C. Lam [03-19-13 - 23:31]
Save memory by not creating many small Lua tables per frame refresh.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@798 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/Ovale.lua b/Ovale.lua
index 03d9b68..ca672fb 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -19,6 +19,7 @@ local pairs = pairs
local strsplit = string.split
local tinsert = table.insert
local tsort = table.sort
+local wipe = table.wipe
local API_GetTime = GetTime
local API_RegisterAddonMessagePrefix = RegisterAddonMessagePrefix
local API_SendAddonMessage = SendAddonMessage
@@ -225,7 +226,7 @@ function Ovale:UpdateFrame()
self:UpdateVisibility()
- self.checkBoxes = {}
+ wipe(self.checkBoxes)
for k,checkBox in pairs(self.casesACocher) do
self.checkBoxes[k] = LibStub("AceGUI-3.0"):Create("CheckBox");
@@ -241,7 +242,7 @@ function Ovale:UpdateFrame()
self.checkBoxes[k]:SetCallback("OnValueChanged",OnCheckBoxValueChanged)
end
- self.dropDowns = {}
+ wipe(self.dropDowns)
if (self.listes) then
for k,list in pairs(self.listes) do
diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index 57ec64c..4e70855 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -28,8 +28,8 @@ local OvaleSwing = Ovale.OvaleSwing
local floor = floor
local pairs = pairs
local select = select
-local strfind = string.dinf
local tostring = tostring
+local wipe = table.wipe
local API_GetBuildInfo = GetBuildInfo
local API_GetItemCooldown = GetItemCooldown
local API_GetItemCount = GetItemCount
@@ -417,7 +417,11 @@ local function getTargetDead(target)
if self_targetGUID[target] ~= API_UnitGUID(target) then
self_lastSaved[target] = nil
self_targetGUID[target] = API_UnitGUID(target)
- self_savedHealth[target] = {}
+ if self_savedHealth[target] then
+ wipe(self_savedHealth[target])
+ else
+ self_savedHealth[target] = {}
+ end
end
local newHealth = API_UnitHealth(target)
if newHealth then
diff --git a/OvaleFrame.lua b/OvaleFrame.lua
index 97605f4..4c7e91a 100644
--- a/OvaleFrame.lua
+++ b/OvaleFrame.lua
@@ -280,7 +280,7 @@ do
end
end
- Ovale.refreshNeeded = {}
+ wipe(Ovale.refreshNeeded)
if (not Ovale.bug) then
Ovale.traced = false