From faf26552df05146251866a092dd6812999ed578d Mon Sep 17 00:00:00 2001 From: MarcelineVQ Date: Sat, 11 May 2024 13:35:28 -0700 Subject: [PATCH] [ fix ] avoid memory leak from repeated function creation on function checks --- Auras.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Auras.lua b/Auras.lua index b36e58d..579ab27 100644 --- a/Auras.lua +++ b/Auras.lua @@ -28,6 +28,7 @@ local GetSpellName = GetSpellName local UnitIsFriend = UnitIsFriend local UpdateTime, LastUpdate = 0.05, 0 local path, duration, text, count, time +local func_table = {} function MPOWA:OnUpdate(elapsed) LastUpdate = LastUpdate + elapsed @@ -120,7 +121,11 @@ function MPOWA:OnUpdate(elapsed) end if (path["funct"]) then - local f = loadstring(path["funct"]) + local f = func_table[cat] + if not f then + f = loadstring(path["funct"]) + func_table[cat] = f + end if f ~= nil then if f() and self.frames[cat][1]:IsVisible() then self:FShow(cat) @@ -196,7 +201,11 @@ function MPOWA:OnUpdate(elapsed) self:FHide(cat) end if (path["funct"]) then - local f = loadstring(path["funct"]) + local f = func_table[cat] + if not f then + f = loadstring(path["funct"]) + func_table[cat] = f + end if f ~= nil then if f() and self.frames[cat][1]:IsVisible() then self:FShow(cat)