From d5ecdc6c76250307a605b60b9ca1b45e81dbf0d6 Mon Sep 17 00:00:00 2001 From: Bluewhale1337 <295648290+Bluewhale1337@users.noreply.github.com> Date: Sat, 10 Oct 2026 11:41:53 +0200 Subject: [PATCH] gperf: optimize lookups by caching talent ranks, spell IDs, and unit IDs --- HealBot_BonusScanner.lua | 6 ++- HealBot_View_Layout.lua | 90 +++++++++++++++++++++------------------- README.md | 1 + 3 files changed, 53 insertions(+), 44 deletions(-) diff --git a/HealBot_BonusScanner.lua b/HealBot_BonusScanner.lua index d77080d..b27712b 100644 --- a/HealBot_BonusScanner.lua +++ b/HealBot_BonusScanner.lua @@ -77,7 +77,11 @@ function HealBot_BonusScanner:ScanEquipment() HealBot_BonusTooltip:SetOwner(HealBot_BonusTooltip, "ANCHOR_NONE"); HealBot_BonusScanner.temp.bonuses = 0; - HealBot_BonusScanner.temp.sets = {}; + if not HealBot_BonusScanner.temp.sets then + HealBot_BonusScanner.temp.sets = {} + else + for k in pairs(HealBot_BonusScanner.temp.sets) do HealBot_BonusScanner.temp.sets[k] = nil end + end HealBot_BonusScanner.temp.set = ""; for i, slotname in HealBot_BonusScanner.slots do slotid, _ = GetInventorySlotInfo(slotname.. "Slot"); diff --git a/HealBot_View_Layout.lua b/HealBot_View_Layout.lua index 50034f6..defa603 100644 --- a/HealBot_View_Layout.lua +++ b/HealBot_View_Layout.lua @@ -464,8 +464,10 @@ end -- HealBot_Action_SetHealButton: Assigns a unit string to a grid button slot. function HealBot_Action_SetHealButton(index, unit) if not index then - HealBot_Action_HealButtons = {}; - HealBot_Action_UnitButtons = {}; + for k in pairs(HealBot_Action_HealButtons) do HealBot_Action_HealButtons[k] = nil end + for k, v in pairs(HealBot_Action_UnitButtons) do + for j in pairs(v) do v[j] = nil end + end return nil end local button = getglobal("HealBot_Action_HealUnit" .. index); @@ -905,47 +907,47 @@ function HealBot_Action_PartyChanged() HeaderPos[i + 1] = nil; numBars = numBars - 1; end + HealBot_ReleaseTable(order); + HealBot_ReleaseTable(units); + end - last = last + 40 - local PetsValid = numBars; - if HealBot_Config.PetHeals == 1 then - if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin] == 1 then - HeaderPos[i + 1] = HEALBOT_OPTIONS_PETHEALS - numBars = numBars + 1; - numHeaders = numHeaders + 1; + last = last + 40 + local PetsValid = numBars; + if HealBot_Config.PetHeals == 1 then + if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin] == 1 then + HeaderPos[i + 1] = HEALBOT_OPTIONS_PETHEALS + numBars = numBars + 1; + numHeaders = numHeaders + 1; + end + if GetNumRaidMembers() > 0 then + for j = 1, 40 do + local unit = "raidpet" .. j; + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + i = i + 1; + HealBot_Action_SetHealButton(i, unit); + numBars = numBars + 1; + end + if i == last then break end end - if GetNumRaidMembers() > 0 then - for j = 1, 40 do - local unit = "raidpet" .. j; - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then - i = i + 1; - HealBot_Action_SetHealButton(i, unit); - numBars = numBars + 1; - end - if i == last then break end + else + if not HealBot_PetUnits then + HealBot_PetUnits = { "pet", "partypet1", "partypet2", "partypet3", "partypet4" }; + end + for _, unit in ipairs(HealBot_PetUnits) do + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + i = i + 1; + HealBot_Action_SetHealButton(i, unit); + numBars = numBars + 1; end - else - if not HealBot_PetUnits then - HealBot_PetUnits = { "pet", "partypet1", "partypet2", "partypet3", "partypet4" }; - end - for _, unit in ipairs(HealBot_PetUnits) do - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then - i = i + 1; - HealBot_Action_SetHealButton(i, unit); - numBars = numBars + 1; - end - if i == last then break end - end + if i == last then break end end - HealBot_ReleaseTable(order); - HealBot_ReleaseTable(units); - end - if numBars == PetsValid + 1 and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin] == 1 then - HeaderPos[PetsValid + 1] = nil; - numBars = numBars - 1; - numHeaders = numHeaders - 1; - end end + end + if numBars == PetsValid + 1 and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin] == 1 then + HeaderPos[PetsValid + 1] = nil; + numBars = numBars - 1; + numHeaders = numHeaders - 1; + end local bpadding = (HealBot_Config.bpadding and HealBot_Config.bpadding[HealBot_Config.Current_Skin]) or 10 local OffsetY = bpadding; @@ -1125,8 +1127,8 @@ end function HealBot_Action_Reset() HealBot_Action:ClearAllPoints(); HealBot_Action:SetPoint("TOP", "MinimapCluster", "BOTTOM", 7, 10); - HealBot_Action_HealTarget = {}; - HealBot_Action_HealFocus = {}; + for k in pairs(HealBot_Action_HealTarget) do HealBot_Action_HealTarget[k] = nil end + for k in pairs(HealBot_Action_HealFocus) do HealBot_Action_HealFocus[k] = nil end HealBot_Action_PartyChanged(); end @@ -1306,6 +1308,10 @@ local HealBot_PlayerHoTs_ValidHoTs = { local HealBot_PlayerHoTs_ListCache = {} +local function HealBot_PlayerHoTs_SortComparator(a, b) + return (a.expires or 0) < (b.expires or 0) +end + function HealBot_Action_UpdatePlayerHoTs() if not HealBot_PlayerHoTsListFrame then HealBot_PlayerHoTsListFrame = CreateFrame("Frame", "HealBot_PlayerHoTsListFrame", HealBot_Action) @@ -1351,9 +1357,7 @@ function HealBot_Action_UpdatePlayerHoTs() end -- Sort only the active portion by shifting expired ones to the end - table.sort(HealBot_PlayerHoTs_ListCache, function(a, b) - return (a.expires or 0) < (b.expires or 0) - end) + table.sort(HealBot_PlayerHoTs_ListCache, HealBot_PlayerHoTs_SortComparator) for i = 1, math.max(numHoTs, table.getn(HealBot_PlayerHoTFrames)) do local frame = HealBot_PlayerHoTFrames[i] diff --git a/README.md b/README.md index ee20e16..9b9008a 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Default installation path: `C:\Program Files\World of Warcraft\Interface\AddOns\ **v1.7.5** * **Feature - Test Bars** - Implemented a "Test Bars" button and slider in the Skins options tab, allowing you to spawn and adjust a dummy raid group of up to 40 members without being in a real raid. This allows for easy layout and appearance customization out of combat. * **UI - Cleanup** - While adding new funcionalities I ignored how menus look, just adding things for each tab where there was free space, so now I tried to clean up this convoluted mess I made. Menu Tabs are now aligned and grouped in a manner that makes more sense. +* **Performance Fix - Table Pooling & GC Leaks** - Resolved critical table leaks in emergency heals where pooled tables (`order` and `units`) failed to release when pet heals were disabled, un-nested pet healing from emergency heals, eliminated high-frequency (4 Hz) anonymous closure allocations in `HealBot_Action_UpdatePlayerHoTs`, and implemented in-place key recycling for equipment scanning and grid button tables. **v1.7.4** * **Performance Fix - CPU Spikes** - Fixed massive FPS drops during raid combat. The `HealBot_CheckBuffs` function previously forced the client to generate hidden UI tooltips for up to 32 buffs per player on every single `UNIT_AURA` event. Tooltip parsing is now cached per texture, bypassing thousands of redundant API calls per second.