2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

yuzu/game_list_worker: Don't retrieve the file type twice in AddFstEntriesToGameList()

Similarly, here we can avoid doing unnecessary work twice by retrieving
the file type only once and comparing it against relevant operands,
avoiding potential unnecessary object construction/destruction.
This commit is contained in:
Lioncash 2018-12-05 17:58:11 -05:00
parent de095ded5c
commit 01bf329f63

View file

@ -198,12 +198,16 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
const bool is_dir = FileUtil::IsDirectory(physical_name); const bool is_dir = FileUtil::IsDirectory(physical_name);
if (!is_dir && if (!is_dir &&
(HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) {
std::unique_ptr<Loader::AppLoader> loader = auto loader = Loader::GetLoader(vfs->OpenFile(physical_name, FileSys::Mode::Read));
Loader::GetLoader(vfs->OpenFile(physical_name, FileSys::Mode::Read)); if (!loader) {
if (!loader || ((loader->GetFileType() == Loader::FileType::Unknown ||
loader->GetFileType() == Loader::FileType::Error) &&
!UISettings::values.show_unknown))
return true; return true;
}
const auto file_type = loader->GetFileType();
if ((file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error) &&
!UISettings::values.show_unknown) {
return true;
}
std::vector<u8> icon; std::vector<u8> icon;
const auto res1 = loader->ReadIcon(icon); const auto res1 = loader->ReadIcon(icon);