From 14516d62db6a5f1c521a7364b721c497a234d982 Mon Sep 17 00:00:00 2001 From: OldManAlpha <60587722+OldManAlpha@users.noreply.github.com> Date: Wed, 27 Aug 2025 17:33:45 -0700 Subject: [PATCH] Massively improve aura update performance --- libs/PTUnit.lua | 28 ++++++++++++---------------- libs/Util.lua | 27 ++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/libs/PTUnit.lua b/libs/PTUnit.lua index 17d8ff1..12c958c 100644 --- a/libs/PTUnit.lua +++ b/libs/PTUnit.lua @@ -10,6 +10,7 @@ local GetAuraInfo = util.GetAuraInfo local AllUnits = util.AllUnits local AllUnitsSet = util.AllUnitsSet local superwow = util.IsSuperWowPresent() +local canGetAuraIDs = util.CanClientGetAuraIDs() local compost = AceLibrary("Compost-2.0") @@ -208,20 +209,16 @@ function PTUnit:ClearAuras() end compost:Reclaim(self.Buffs, 1) compost:Reclaim(self.BuffsMap, 1) - compost:Reclaim(self.BuffsIDSet) + compost:Erase(self.BuffsIDSet) compost:Reclaim(self.Debuffs, 1) compost:Reclaim(self.DebuffsMap, 1) - compost:Reclaim(self.DebuffsIDSet) - compost:Reclaim(self.TypedDebuffs) - compost:Reclaim(self.AfflictedDebuffTypes) + compost:Erase(self.DebuffsIDSet) + compost:Erase(self.TypedDebuffs) + compost:Erase(self.AfflictedDebuffTypes) self.Buffs = compost:GetTable() self.BuffsMap = compost:GetTable() - self.BuffsIDSet = compost:GetTable() self.Debuffs = compost:GetTable() self.DebuffsMap = compost:GetTable() - self.DebuffsIDSet = compost:GetTable() - self.TypedDebuffs = compost:GetTable() - self.AfflictedDebuffTypes = compost:GetTable() self.HasHealingModifier = false self.AurasPopulated = false end @@ -239,9 +236,6 @@ function PTUnit:UpdateAuras() return end - local PT = Puppeteer - - -- Track player buffs local buffs = self.Buffs local buffsMap = self.BuffsMap local buffsIDSet = self.BuffsIDSet @@ -250,7 +244,7 @@ function PTUnit:UpdateAuras() if not texture then break end - local name, type = GetAuraInfo(unit, "Buff", index) + local name, type = GetAuraInfo(unit, index, "Buff", id) if PuppeteerSettings.TrackedHealingBuffs[name] then self.HasHealingModifier = true end @@ -266,7 +260,6 @@ function PTUnit:UpdateAuras() end local afflictedDebuffTypes = self.AfflictedDebuffTypes - -- Track player debuffs local debuffs = self.Debuffs local debuffsMap = self.DebuffsMap local debuffsIDSet = self.DebuffsIDSet @@ -277,7 +270,7 @@ function PTUnit:UpdateAuras() break end type = type or "" - local name = GetAuraInfo(unit, "Debuff", index) + local name = GetAuraInfo(unit, index, "Debuff", id) if PuppeteerSettings.TrackedHealingDebuffs[name] then self.HasHealingModifier = true end @@ -312,7 +305,7 @@ end -- Looks for ID if SuperWoW/Turtle WoW is present, otherwise searches by name function PTUnit:HasBuffIDOrName(id, name) - if superwow then + if canGetAuraIDs then return self:HasBuffID(id) end return self:HasBuff(name) @@ -329,7 +322,7 @@ end -- Looks for ID if SuperWoW/Turtle WoW is present, otherwise searches by name function PTUnit:HasDebuffIDOrName(id, name) - if superwow then + if canGetAuraIDs then return self:HasDebuffID(id) end return self:HasDebuff(name) @@ -364,6 +357,9 @@ function PTUnit:GetDebuffs(name) end function PTUnit:GetAuraTimeRemaining(name) + if not superwow then + return + end local auraTime = self.AuraTimes[name] if not auraTime then return diff --git a/libs/Util.lua b/libs/Util.lua index dbddc07..0be7f01 100644 --- a/libs/Util.lua +++ b/libs/Util.lua @@ -593,7 +593,7 @@ function GetResourceCost(spellName) end -- Returns the aura's name and its school type -function GetAuraInfo(unit, type, index) +function ScanAuraInfo(unit, index, type) -- Make these texts blank since they don't clear otherwise local leftText = _G["PTScanningTooltipTextLeft1"] leftText:SetText("") @@ -607,6 +607,27 @@ function GetAuraInfo(unit, type, index) return leftText:GetText() or "", rightText:GetText() or "" end +if SuperWoW or TurtleWow then + local auraNameCache = {} + local auraTypeCache = {} + + function GetAuraInfo(unit, index, type, id) + if not id then + id = type == "Buff" and UnitBuff(unit, index) or UnitDebuff(unit, index) + end + if not auraNameCache[id] then + auraNameCache[id], auraTypeCache[id] = ScanAuraInfo(unit, index, type) + end + return auraNameCache[id], auraTypeCache[id] + end + + function GetCachedAuraInfo(id) + return auraNameCache[id], auraTypeCache[id] + end +else + GetAuraInfo = ScanAuraInfo +end + -- Returns an array of the units in the party number or the unit's raid group function GetRaidPartyMembers(partyNumberOrUnit) if not RAID_SUBGROUP_LISTS then @@ -1151,6 +1172,10 @@ function CanClientSightCheck() return UnitXPSP3 end +function CanClientGetAuraIDs() + return SuperWoW or TurtleWow +end + function IsSuperWowPresent() return SuperWoW end