refactor: cache macro primary spell ID to avoid per-frame name search

The macro cooldown display from the previous commit iterated all known
spells (400+) every frame for each macro on the action bar, doing
lowercase string comparisons. Moved the spell name resolution into a
cached lookup (macroPrimarySpellCache_) that only runs once per macro
and is invalidated when macro text is edited. The per-frame path now
just does a single hash map lookup + spellCooldowns check.
This commit is contained in:
Kelsi 2026-03-20 08:11:13 -07:00
parent 670055b873
commit bfbf590ee2
2 changed files with 53 additions and 40 deletions

View file

@ -435,6 +435,10 @@ private:
void loadExtendedCostDBC();
std::string formatExtendedCost(uint32_t extendedCostId, game::GameHandler& gameHandler);
// Macro cooldown cache: maps macro slot index → resolved primary spell ID (0 = no spell found)
std::unordered_map<int, uint32_t> macroPrimarySpellCache_;
uint32_t resolveMacroPrimarySpellId(int slotIndex, game::GameHandler& gameHandler);
// Death Knight rune bar: client-predicted fill (0.0=depleted, 1.0=ready) for smooth animation
float runeClientFill_[6] = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};