From 1d44c5ec6f4419c63b19402961740272730be280 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sun, 23 Aug 2026 13:05:29 -0500 Subject: [PATCH] unitframes: scan debuff slots once for dispel indicators The dispellable-indicator block re-scanned all 16 harmful slots for every dispellable type (O(types x 16) UnitDebuff calls per refresh). Scan the 16 slots once into a reusable set, then have the per-type loop check the set. Zero-allocation (the set is cleared and reused within the single RefreshUnit call). --- api/unitframes.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 7c11f514..b74e34ae 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -1828,6 +1828,17 @@ function pfUI.uf:RefreshUnit(unit, component) end end + -- Scan the 16 harmful slots once into a reusable set, instead of + -- re-scanning all 16 for every dispellable type below. Reused across + -- frames (populated and consumed within this single RefreshUnit call). + local present = pfUI.uf.dispelPresent or {} + pfUI.uf.dispelPresent = present + for k in pairs(present) do present[k] = nil end + for i=1,16 do + local name, _, _, dispelType = C_UnitAuras.UnitDebuff(unitstr, i) + if name and dispelType and dispelType ~= "" then present[dispelType] = true end + end + for _, debuff in pairs(unit.dispellable) do indicator[debuff] = indicator[debuff] or CreateFrame("Frame", nil, indicator) indicator[debuff]:SetParent(indicator) @@ -1867,15 +1878,7 @@ function pfUI.uf:RefreshUnit(unit, component) indicator[debuff].disp = indicator.disp end - indicator[debuff].visible = nil - - for i=1,16 do - -- positional read: only the dispel type is needed, so allocate no table - local name, _, _, dispelType = C_UnitAuras.UnitDebuff(unitstr, i) - if name and dispelType == debuff then - indicator[debuff].visible = true - end - end + indicator[debuff].visible = present[debuff] if indicator[debuff].visible then indicator[debuff]:Show()