summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-12-04 18:39:32 -0500
committerGravatar Lioncash2018-12-04 18:39:35 -0500
commita49fd7fd57ed9a2a1a40dc0b99942bd1b18db414 (patch)
tree13c35104a52050ed53af972552b00adccc5ef435 /src
parentyuzu/game_list_worker: Deduplicate game list entry creation (diff)
downloadyuzu-a49fd7fd57ed9a2a1a40dc0b99942bd1b18db414.tar.gz
yuzu-a49fd7fd57ed9a2a1a40dc0b99942bd1b18db414.tar.xz
yuzu-a49fd7fd57ed9a2a1a40dc0b99942bd1b18db414.zip
yuzu/game_list_worker: Move std::string construction after the termination check in callbacks
Avoids potentially allocating a std::string instance when it isn't needed.
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/game_list_worker.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp
index 3d8787dd0..6d41809fb 100644
--- a/src/yuzu/game_list_worker.cpp
+++ b/src/yuzu/game_list_worker.cpp
@@ -163,13 +163,12 @@ void GameListWorker::AddInstalledTitlesToGameList() {
163void GameListWorker::FillControlMap(const std::string& dir_path) { 163void GameListWorker::FillControlMap(const std::string& dir_path) {
164 const auto nca_control_callback = [this](u64* num_entries_out, const std::string& directory, 164 const auto nca_control_callback = [this](u64* num_entries_out, const std::string& directory,
165 const std::string& virtual_name) -> bool { 165 const std::string& virtual_name) -> bool {
166 const std::string physical_name = directory + DIR_SEP + virtual_name;
167
168 if (stop_processing) { 166 if (stop_processing) {
169 // Breaks the callback loop 167 // Breaks the callback loop
170 return false; 168 return false;
171 } 169 }
172 170
171 const std::string physical_name = directory + DIR_SEP + virtual_name;
173 const QFileInfo file_info(QString::fromStdString(physical_name)); 172 const QFileInfo file_info(QString::fromStdString(physical_name));
174 if (!file_info.isDir() && file_info.suffix() == QStringLiteral("nca")) { 173 if (!file_info.isDir() && file_info.suffix() == QStringLiteral("nca")) {
175 auto nca = 174 auto nca =
@@ -188,12 +187,13 @@ void GameListWorker::FillControlMap(const std::string& dir_path) {
188void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) { 187void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) {
189 const auto callback = [this, recursion](u64* num_entries_out, const std::string& directory, 188 const auto callback = [this, recursion](u64* num_entries_out, const std::string& directory,
190 const std::string& virtual_name) -> bool { 189 const std::string& virtual_name) -> bool {
191 std::string physical_name = directory + DIR_SEP + virtual_name; 190 if (stop_processing) {
192 191 // Breaks the callback loop.
193 if (stop_processing) 192 return false;
194 return false; // Breaks the callback loop. 193 }
195 194
196 bool is_dir = FileUtil::IsDirectory(physical_name); 195 const std::string physical_name = directory + DIR_SEP + virtual_name;
196 const bool is_dir = FileUtil::IsDirectory(physical_name);
197 if (!is_dir && 197 if (!is_dir &&
198 (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { 198 (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) {
199 std::unique_ptr<Loader::AppLoader> loader = 199 std::unique_ptr<Loader::AppLoader> loader =