perf: pre-allocate raid unit tokens to optimize HealBot_FindUnitID performance

This commit is contained in:
Bluewhale1337
2026-10-01 22:27:41 +02:00
parent eb7cbc52f2
commit 59e3701d79
2 changed files with 18 additions and 14 deletions
+15 -14
View File
@@ -222,25 +222,26 @@ end
-- SpiBonus and GetBonus functions moved to HealBot_Controller_Spells.lua
local HealBot_RaidUnitTokens = {}
for i=1, 40 do HealBot_RaidUnitTokens[i] = "raid"..i end
-- HealBot_FindUnitID: Finds a unit token for a given player name.
function HealBot_FindUnitID(unitname)
local text;
for _,unit in ipairs(HealBot_Action_HealGroup) do
text = UnitName(unit);
if text then
if text==unitname then
return unit;
end
end
end
for i=1,40 do
local unit = "raid"..i;
text = UnitName(unit);
if text then
if text==unitname then
if HealBot_Action_HealGroup then
for _,unit in ipairs(HealBot_Action_HealGroup) do
text = UnitName(unit);
if text and text==unitname then
return unit;
end
end
end
end
for i=1,40 do
local unit = HealBot_RaidUnitTokens[i];
text = UnitName(unit);
if text and text==unitname then
return unit;
end
end
return nil;
end
+3
View File
@@ -49,6 +49,9 @@ Default installation path: `C:\Program Files\World of Warcraft\Interface\AddOns\
### Change Log
**v1.7.4**
* **Performance Fix - Unit ID Lookup** - Optimized `HealBot_FindUnitID` by pre-allocating raid unit tokens, preventing massive string concatenation and garbage collection spam during high-frequency combat events like `CHAT_MSG_ADDON` (HealComm).
**v1.7.3**
* **Performance Fix - Table Pooling Part 2** - Fixed remaining un-pooled table allocations in layout updates, macro parsing, nampower integration, and aura tracking by utilizing HealBot_GetTable().
* **Performance Fix - HealComm Networking** - Fixed issue where incoming `HealComm` messages triggered synchronous UI redraws, causing massive lag in 40-man raids during combat. `HealBot_RecalcHeals` is now decoupled and deferred through the `HealBot_OnUpdate` dirty queue, allowing multiple network events to collapse into a single frame redraw.