From 38c5ca68b244de84ba3ad258e726ab74b0c1f9cb Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Mon, 22 Jan 2018 07:56:24 -0600 Subject: [PATCH] reduce the scope of the variables --- src/citra_qt/game_list.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 12dc8d0b2..65cba7006 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -402,23 +402,27 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign u64 program_id = 0; loader->ReadProgramId(program_id); - std::vector update_smdh; - std::string update_path; - u64 update_id = 0; - std::unique_ptr update_loader = nullptr; + std::vector update_smdh = [program_id]() -> std::vector { + if (0x4000000000000 > program_id && program_id > 0x40000FFFFFFFF) + return {}; - if (0x4000000000000 <= program_id && program_id <= 0x40000FFFFFFFF) { - update_id = program_id + 0xe00000000; - update_path = + u64 update_id = program_id + 0xe00000000; + std::string update_path = Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, update_id); - if (FileUtil::Exists(update_path)) { - update_loader = Loader::GetLoader(update_path); - if (update_loader) { - update_loader->ReadIcon(update_smdh); - update_loader->ReadProgramId(update_id); - } - } - } + + if (!FileUtil::Exists(update_path)) + return {}; + + std::unique_ptr update_loader = Loader::GetLoader(update_path); + + if (!update_loader) + return {}; + + std::vector update_smdh; + update_loader->ReadIcon(update_smdh); + update_loader->ReadProgramId(update_id); + return update_smdh; + }(); emit EntryReady({ new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id,