Cache MPQ file->archive lookups to prevent character select stalls

This commit is contained in:
Kelsi 2026-02-12 15:51:17 -08:00
parent 652f9e64fc
commit f5f757332a
2 changed files with 72 additions and 6 deletions

View file

@ -5,6 +5,7 @@
#include <cstdint>
#include <memory>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <mutex>
@ -108,6 +109,12 @@ private:
void logMissingFileOnce(const std::string& filename) const;
// Cache for mapping "virtual filename" -> archive handle (or INVALID_HANDLE_VALUE for not found).
// This avoids scanning every archive for repeated lookups, which can otherwise appear as a hang
// on screens that trigger many asset probes (character select, character preview, etc.).
mutable std::mutex fileArchiveCacheMutex_;
mutable std::unordered_map<std::string, HANDLE> fileArchiveCache_;
mutable std::mutex missingFileMutex_;
mutable std::unordered_set<std::string> missingFileWarnings_;
};