Fix WAV decode cache and spell lookup performance

- audio_engine.cpp: cache key was based on vector pointer address, not
  content — cache never hit since each asset load produces a new
  allocation. Replace with FNV-1a over head+tail bytes + size, giving
  correct content-based identity at O(1) cost. Add 256-entry cap with
  eviction to prevent unbounded growth over long sessions.

- game_handler.hpp/cpp, spellbook_screen, game_screen: knownSpells was
  a std::vector with O(n) std::find lookups scattered across packet
  handlers and UI code. Switch to std::unordered_set for O(1) insert,
  erase, and membership checks. Update all push_back/erase-remove/find
  call sites to use set operations.
This commit is contained in:
Kelsi 2026-02-17 15:13:54 -08:00
parent e29b67dad9
commit 827679579f
6 changed files with 47 additions and 36 deletions

View file

@ -4860,7 +4860,7 @@ void GameScreen::renderTrainerWindow(game::GameHandler& gameHandler) {
auto isKnown = [&](uint32_t id) {
if (id == 0) return true;
// Check if spell is in knownSpells list
bool found = std::find(knownSpells.begin(), knownSpells.end(), id) != knownSpells.end();
bool found = knownSpells.count(id);
if (found) return true;
// Also check if spell is in trainer list with state=2 (explicitly known)