filesystem: Cache RegisteredCacheUnion instead of constructing on demand
Prevents unnecessary re-reads of the metadata and unnecessary temporary objects.
This commit is contained in:
parent
97d425c304
commit
8f183a47dd
2 changed files with 11 additions and 4 deletions
|
@ -319,11 +319,18 @@ 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() {
|
||||||
LOG_TRACE(Service_FS, "Opening System NAND Contents");
|
LOG_TRACE(Service_FS, "Opening System NAND Contents");
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in a new issue