mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-07 14:10:01 +00:00
auras: scan through GetAuraSlots instead of by-index loops
Every aura scan loop (unit frame buffs/debuffs, dispel indicators, buff and custom indicators, player buff frame, buffwatch bars, tooltip buff row) now enumerates a unit's auras once with C_UnitAuras.GetAuraSlots and reads each aura by slot id via the positional C_UnitAuras.UnitAuraBySlot. The by-index getters re-walk the aura array from slot 0 on every call, so a per-button loop over them was quadratic in the aura count; one enumeration plus a by-slot read per aura is linear. pfUI.api.ScanAuraSlots(unit, filter, buf, max) wraps GetAuraSlots' fill-a- table form (table as the 5th argument) so no vararg Lua frame is involved: Lua 5.0 allocates an `arg` table for every vararg call, which showed up as nameplate OnUpdate/OnEvent memory growth in the first cut of this change. Single by-index reads in tooltip and click handlers are unchanged (one call each, and SetUnitAura takes the same index). Requires the ClassicAPI build that adds GetAuraSlots' fill form; on an older DLL the 5th argument is ignored and ScanAuraSlots would read the first slot id as the count.
This commit is contained in:
+13
-4
@@ -73,9 +73,12 @@ pfUI:RegisterModule("buffwatch", function ()
|
||||
return anchor
|
||||
end
|
||||
|
||||
local function GetBuffData(unit, id, type, selfdebuff)
|
||||
local filter = (selfdebuff and type == "HARMFUL") and "HARMFUL|PLAYER" or type
|
||||
local name, icon, count, dispelType, _, expirationTime = C_UnitAuras.UnitAura(unit, id, filter)
|
||||
-- reusable GetAuraSlots buffer, filled once per RefreshBuffBarFrame
|
||||
local auraSlots = {}
|
||||
|
||||
-- Reads one aura by the slot id GetAuraSlots returned (nil slot -> nil).
|
||||
local function GetBuffData(unit, slot)
|
||||
local name, icon, count, dispelType, _, expirationTime = C_UnitAuras.UnitAuraBySlot(unit, slot)
|
||||
if not name then return end
|
||||
local remaining = expirationTime > 0 and (expirationTime - GetTime()) or 0
|
||||
return remaining, icon, name, count, dispelType
|
||||
@@ -234,9 +237,15 @@ pfUI:RegisterModule("buffwatch", function ()
|
||||
local function RefreshBuffBarFrame(frame)
|
||||
-- reinitialize all active buffs
|
||||
local selfdebuff = frame.config.selfdebuff == "1"
|
||||
local filter = (selfdebuff and frame.type == "HARMFUL") and "HARMFUL|PLAYER" or frame.type
|
||||
|
||||
-- one GetAuraSlots enumeration per refresh instead of a by-index walk per
|
||||
-- bar; the i-th slot is the i-th aura of the filtered list, so `i` stays
|
||||
-- the index the tooltip / cancel handlers pass to the by-index API
|
||||
ScanAuraSlots(frame.unit, filter, auraSlots, 32)
|
||||
|
||||
for i=1,32 do
|
||||
local timeleft, texture, name, stacks, dtype = GetBuffData(frame.unit, i, frame.type, selfdebuff)
|
||||
local timeleft, texture, name, stacks, dtype = GetBuffData(frame.unit, auraSlots[i])
|
||||
timeleft = timeleft or 0
|
||||
|
||||
if texture and name and name ~= "" and BuffIsVisible(frame.config, name) then
|
||||
|
||||
Reference in New Issue
Block a user