perf: entity/skill/DBC/warden maps to unordered_map; fix 3x contacts scan

Entity storage: std::map<uint64_t, shared_ptr<Entity>> → unordered_map for
O(1) entity lookups instead of O(log n). No code depends on GUID ordering.

Player skills: std::map<uint32_t, PlayerSkill> → unordered_map.
DBC ID cache: std::map<uint32_t, uint32_t> → unordered_map.
Warden: apiHandlers_ and allocations_ → unordered_map (freeBlocks_ kept
as std::map since its coalescing logic requires ordered iteration).

Contacts: handleFriendStatus() did 3 separate O(n) find_if scans per
packet. Consolidated to single find_if with iterator reuse. O(3n) → O(n).
This commit is contained in:
Kelsi 2026-03-27 18:28:36 -07:00
parent 2af3594ce8
commit e61b23626a
5 changed files with 20 additions and 21 deletions

View file

@ -1,7 +1,7 @@
#pragma once
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <string_view>
#include <cstdint>
@ -137,7 +137,7 @@ private:
std::vector<uint8_t> stringBlock; // String block
// Cache for record ID -> index lookup
mutable std::map<uint32_t, uint32_t> idToIndexCache;
mutable std::unordered_map<uint32_t, uint32_t> idToIndexCache;
mutable bool idCacheBuilt = false;
void buildIdCache() const;