mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-05 05:00:02 +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:
+16
-1
@@ -7,6 +7,15 @@ pfUI:RegisterModule("buff", function ()
|
||||
|
||||
local br, bg, bb, ba = GetStringColor(pfUI_config.appearance.border.color)
|
||||
|
||||
-- Player aura slot ids, enumerated once per refresh pass (ScanPlayerAuraSlots)
|
||||
-- and read per button by its aura index: one GetAuraSlots walk per range
|
||||
-- instead of a by-index walk per button.
|
||||
local helpfulSlots, harmfulSlots = {}, {}
|
||||
local function ScanPlayerAuraSlots()
|
||||
ScanAuraSlots("player", "HELPFUL", helpfulSlots, 32)
|
||||
ScanAuraSlots("player", "HARMFUL", harmfulSlots, 16)
|
||||
end
|
||||
|
||||
local function RefreshBuffButton(buff)
|
||||
if buff.btype == "HELPFUL" then
|
||||
if C.buffs.separateweapons == "1" then
|
||||
@@ -23,7 +32,8 @@ pfUI:RegisterModule("buff", function ()
|
||||
CreateBackdropShadow(buff)
|
||||
end
|
||||
|
||||
local name, icon, count, dispelType, _, expirationTime, _, _, _, spellId = C_UnitAuras.UnitAura("player", buff.id, buff.btype)
|
||||
local slots = buff.btype == "HELPFUL" and helpfulSlots or harmfulSlots
|
||||
local name, icon, count, dispelType, _, expirationTime, _, _, _, spellId = C_UnitAuras.UnitAuraBySlot("player", slots[buff.id])
|
||||
|
||||
--detect weapon buffs
|
||||
if buff.btype == "HELPFUL" and ((C.buffs.separateweapons == "0" and buff.gid <= pfUI.buff.wepbuffs.count) or (pfUI.buff.wepbuffs.count > 0 and buff.weapon ~= nil)) then
|
||||
@@ -166,6 +176,8 @@ pfUI:RegisterModule("buff", function ()
|
||||
pfUI.buff.wepbuffs.count = 0
|
||||
end
|
||||
|
||||
ScanPlayerAuraSlots()
|
||||
|
||||
for i=1,32 do
|
||||
RefreshBuffButton(pfUI.buff.buffs.buttons[i])
|
||||
end
|
||||
@@ -246,6 +258,9 @@ pfUI:RegisterModule("buff", function ()
|
||||
end
|
||||
end)
|
||||
|
||||
-- CreateBuffButton refreshes each new button from the slot buffers
|
||||
ScanPlayerAuraSlots()
|
||||
|
||||
-- Weapon Buffs
|
||||
pfUI.buff.wepbuffs = CreateFrame("Frame", "pfWepBuffFrame", UIParent)
|
||||
pfUI.buff.wepbuffs.count = 0
|
||||
|
||||
Reference in New Issue
Block a user