Filesystem: Add a cache for finding file info by disc offset

FileMonitor calls this every time a read happens, and there's no code that
only calls this a small number of times, so having a cache is worthwhile.
This commit is contained in:
JosJuice
2015-08-09 13:41:41 +02:00
parent 87916fe099
commit ee27be06d7
2 changed files with 21 additions and 17 deletions

View File

@ -5,6 +5,7 @@
#pragma once
#include <cstddef>
#include <map>
#include <memory>
#include <optional>
#include <string>
@ -101,9 +102,10 @@ private:
u32 m_offset_shift;
std::vector<u8> m_file_system_table;
FileInfoGCWii m_root;
// Maps the end offset of files to FST indexes
mutable std::map<u64, u32> m_offset_file_info_cache;
std::unique_ptr<FileInfo> FindFileInfo(const std::string& path, const FileInfo& file_info) const;
std::unique_ptr<FileInfo> FindFileInfo(u64 disc_offset, const FileInfo& file_info) const;
};
} // namespace