From 42bc9066eeae5f805ff24377607679930fed1b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 13 Nov 2021 22:47:29 +0100 Subject: [PATCH] Add shortcut for content_uri and native paths in CleanRecent. Saves 150ms. --- Core/Config.cpp | 23 ++++++++++++++++++++--- Windows/MainWindow.cpp | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 8143123e88..a0267b51bb 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -29,6 +29,7 @@ #include "Common/Net/URL.h" #include "Common/Log.h" +#include "Common/TimeUtil.h" #include "Common/Data/Format/IniFile.h" #include "Common/Data/Format/JSONReader.h" #include "Common/Data/Text/I18n.h" @@ -1643,18 +1644,34 @@ void Config::RemoveRecent(const std::string &file) { } void Config::CleanRecent() { + double startTime = time_now_d(); + std::vector cleanedRecent; for (size_t i = 0; i < recentIsos.size(); i++) { - FileLoader *loader = ConstructFileLoader(Path(recentIsos[i])); - if (loader->ExistsFast()) { + bool exists = false; + Path path = Path(recentIsos[i]); + switch (path.Type()) { + case PathType::CONTENT_URI: + case PathType::NATIVE: + exists = File::Exists(path); + break; + default: + FileLoader *loader = ConstructFileLoader(path); + exists = loader->ExistsFast(); + delete loader; + break; + } + + if (exists) { // Make sure we don't have any redundant items. auto duplicate = std::find(cleanedRecent.begin(), cleanedRecent.end(), recentIsos[i]); if (duplicate == cleanedRecent.end()) { cleanedRecent.push_back(recentIsos[i]); } } - delete loader; } + + INFO_LOG(SYSTEM, "CleanRecent took %0.2f", time_now_d() - startTime); recentIsos = cleanedRecent; } diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 12ba10517b..12dd5e0fb7 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -541,12 +541,12 @@ namespace MainWindow } void CreateGeDebuggerWindow() { - if (!geDebuggerWindow) { #if PPSSPP_API(ANY_GL) + if (!geDebuggerWindow) { geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND()); DialogManager::AddDlg(geDebuggerWindow); -#endif } +#endif } void CreateMemoryWindow() {