yuzu-emu
/
yuzu
Archived
1
0
Fork 0

filesystem: Cache RegisteredCacheUnion instead of constructing on demand

Prevents unnecessary re-reads of the metadata and unnecessary temporary objects.
This commit is contained in:
Zach Hilman 2018-11-01 20:24:32 -04:00
parent 97d425c304
commit 8f183a47dd
2 changed files with 11 additions and 4 deletions

View File

@ -319,9 +319,16 @@ ResultVal<FileSys::VirtualDir> OpenSDMC() {
return sdmc_factory->Open(); return sdmc_factory->Open();
} }
std::unique_ptr<FileSys::RegisteredCacheUnion> GetUnionContents() { std::shared_ptr<FileSys::RegisteredCacheUnion> registered_cache_union;
return std::make_unique<FileSys::RegisteredCacheUnion>(std::vector<FileSys::RegisteredCache*>{
std::shared_ptr<FileSys::RegisteredCacheUnion> GetUnionContents() {
if (registered_cache_union == nullptr) {
registered_cache_union =
std::make_shared<FileSys::RegisteredCacheUnion>(std::vector<FileSys::RegisteredCache*>{
GetSystemNANDContents(), GetUserNANDContents(), GetSDMCContents()}); GetSystemNANDContents(), GetUserNANDContents(), GetSDMCContents()});
}
return registered_cache_union;
} }
FileSys::RegisteredCache* GetSystemNANDContents() { FileSys::RegisteredCache* GetSystemNANDContents() {

View File

@ -47,7 +47,7 @@ ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space,
FileSys::SaveDataDescriptor save_struct); FileSys::SaveDataDescriptor save_struct);
ResultVal<FileSys::VirtualDir> OpenSDMC(); ResultVal<FileSys::VirtualDir> OpenSDMC();
std::unique_ptr<FileSys::RegisteredCacheUnion> GetUnionContents(); std::shared_ptr<FileSys::RegisteredCacheUnion> GetUnionContents();
FileSys::RegisteredCache* GetSystemNANDContents(); FileSys::RegisteredCache* GetSystemNANDContents();
FileSys::RegisteredCache* GetUserNANDContents(); FileSys::RegisteredCache* GetUserNANDContents();