From bed17c9148bec7086fd262bf68a1009070150d8f Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Tue, 19 Mar 2013 23:31:11 +0000 Subject: [PATCH] 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 --- Ovale.lua | 5 +++-- OvaleCondition.lua | 8 ++++++-- OvaleFrame.lua | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) 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 -- 1.7.9.5