fix: Added isUnusable detection with caching

This commit is contained in:
Salikh Gurgenidze
2026-01-24 12:36:48 +04:00
parent 06db5f15fa
commit 52af32daaa
12 changed files with 198 additions and 258 deletions
+33
View File
@@ -5,6 +5,39 @@ local addon = Guda
local Utils = {}
addon.Modules.Utils = Utils
--=============================================================================
-- Timer Frame Pool (prevents memory leaks from temporary timers)
-- Global function so all modules can use it
--=============================================================================
local timerPool = {}
local TIMER_POOL_MAX = 10 -- Limit pool size to prevent unbounded growth
function Guda_ScheduleTimer(delay, callback)
-- Try to get a frame from the pool
local frame = table.remove(timerPool)
if not frame then
frame = CreateFrame("Frame")
end
frame.elapsed = 0
frame.delay = delay
frame.callback = callback
frame:SetScript("OnUpdate", function()
this.elapsed = this.elapsed + arg1
if this.elapsed >= this.delay then
this:SetScript("OnUpdate", nil)
this:Hide()
-- Return frame to pool if not full
if table.getn(timerPool) < TIMER_POOL_MAX then
table.insert(timerPool, this)
end
-- Execute callback
this.callback()
end
end)
frame:Show()
end
--=============================================================================
-- Tooltip Scan Caching
-- Caches results of expensive tooltip scanning operations