From 5a625fe945cb5c272a2e08d706ddef14c9a3c6fb Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Fri, 7 Dec 2018 16:53:15 +0100 Subject: [PATCH] yuzu/game_list_worker: Move std::string construction after the termintion check in callbacks Avoids potentially allocating a std::string instance when it isn't needed. --- src/citra_qt/game_list_worker.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/citra_qt/game_list_worker.cpp b/src/citra_qt/game_list_worker.cpp index 7ec7c7677..8739153f0 100644 --- a/src/citra_qt/game_list_worker.cpp +++ b/src/citra_qt/game_list_worker.cpp @@ -37,12 +37,13 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign const auto callback = [this, recursion, parent_dir](u64* num_entries_out, const std::string& directory, const std::string& virtual_name) -> bool { - std::string physical_name = directory + DIR_SEP + virtual_name; + if (stop_processing) { + // Breaks the callback loop. + return false; + } - if (stop_processing) - return false; // Breaks the callback loop. - - bool is_dir = FileUtil::IsDirectory(physical_name); + const std::string physical_name = directory + DIR_SEP + virtual_name; + const bool is_dir = FileUtil::IsDirectory(physical_name); if (!is_dir && HasSupportedFileExtension(physical_name)) { std::unique_ptr loader = Loader::GetLoader(physical_name); if (!loader)