diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index f47a6f5d53..30481af93b 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1212,7 +1212,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int } else { // The hacky way to get the display layout config (normally we pass it down, but it would require a lot of plumbing here). // This is only for non-buffered rendering. - auto config = g_Config.GetDisplayLayoutConfig(g_display.GetDeviceOrientation()); + const auto& config = g_Config.GetDisplayLayoutConfig(g_display.GetDeviceOrientation()); // Here config is valid. _dbg_assert_(channel == RASTER_COLOR); // We are drawing directly to the back buffer so need to flip. diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 417ddbbe4f..89b9ef0185 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -75,7 +75,7 @@ GameInfo::~GameInfo() { fileLoader.reset(); } -bool IsReasonableEbootDirectory(Path path) { +bool IsReasonableEbootDirectory(const Path& path) { // First some sanity checks. if (path == Path("/")) { return false; @@ -250,7 +250,7 @@ std::string GameInfo::GetMTime() const { // Not too meaningful if the object itself is a savedata directory... // Call this under lock. -std::vector GameInfo::GetSaveDataDirectories() { +std::vector GameInfo::GetSaveDataDirectories() const { if (!(hasFlags & GameInfoFlags::PARAM_SFO)) { ERROR_LOG(Log::UI, "Can't get savedata directories if we don't have PARAM_SFO."); return std::vector(); @@ -268,14 +268,14 @@ std::vector GameInfo::GetSaveDataDirectories() { const std::string &prefix = id; File::GetFilesInDir(memc, &dirs, nullptr, 0, prefix); - for (size_t i = 0; i < dirs.size(); i++) { - directories.push_back(dirs[i].fullName); + for (const auto& dir : dirs) { + directories.push_back(dir.fullName); } return directories; } -u64 GameInfo::GetGameSavedataSizeInBytes() { +u64 GameInfo::GetGameSavedataSizeInBytes() const { if (fileType == IdentifiedFileType::PSP_SAVEDATA_DIRECTORY || fileType == IdentifiedFileType::PPSSPP_SAVESTATE) { return 0; } @@ -283,9 +283,9 @@ u64 GameInfo::GetGameSavedataSizeInBytes() { u64 totalSize = 0; u64 filesSizeInDir = 0; - for (size_t j = 0; j < saveDataDir.size(); j++) { + for (const auto& dir : saveDataDir) { std::vector fileInfo; - File::GetFilesInDir(saveDataDir[j], &fileInfo); + File::GetFilesInDir(dir, &fileInfo); for (auto const &file : fileInfo) { if (!file.isDirectory) filesSizeInDir += file.size; @@ -299,7 +299,7 @@ u64 GameInfo::GetGameSavedataSizeInBytes() { return totalSize; } -u64 GameInfo::GetInstallDataSizeInBytes() { +u64 GameInfo::GetInstallDataSizeInBytes() const { if (fileType == IdentifiedFileType::PSP_SAVEDATA_DIRECTORY || fileType == IdentifiedFileType::PPSSPP_SAVESTATE) { return 0; } @@ -307,9 +307,9 @@ u64 GameInfo::GetInstallDataSizeInBytes() { u64 totalSize = 0; u64 filesSizeInDir = 0; - for (size_t j = 0; j < saveDataDir.size(); j++) { + for (const auto& dir : saveDataDir) { std::vector fileInfo; - File::GetFilesInDir(saveDataDir[j], &fileInfo); + File::GetFilesInDir(dir, &fileInfo); for (auto const &file : fileInfo) { // TODO: Might want to recurse here? Don't know games that use directories // for install-data though. @@ -357,12 +357,12 @@ void GameInfo::DisposeFileLoader() { fileLoader.reset(); } -bool GameInfo::DeleteAllSaveData() { +bool GameInfo::DeleteAllSaveData() const { std::vector saveDataDir = GetSaveDataDirectories(); - for (size_t j = 0; j < saveDataDir.size(); j++) { - INFO_LOG(Log::System, "Deleting savedata from %s", saveDataDir[j].c_str()); - if (!MoveDirectoryTreeToTrashOrDelete(saveDataDir[j])) { - ERROR_LOG(Log::System, "Failed to delete savedata %s", saveDataDir[j].c_str()); + for (const auto& dir : saveDataDir) { + INFO_LOG(Log::System, "Deleting savedata from %s", dir.c_str()); + if (!MoveDirectoryTreeToTrashOrDelete(dir)) { + ERROR_LOG(Log::System, "Failed to delete savedata %s", dir.c_str()); } } return true; @@ -994,7 +994,7 @@ void GameInfoCache::Clear() { void GameInfoCache::CancelAll() { std::lock_guard lock(mapLock_); - for (auto info : info_) { + for (const auto& info : info_) { // GetFileLoader will create one if there isn't one already. // Avoid that by checking. if (info.second->HasFileLoader()) { @@ -1008,15 +1008,15 @@ void GameInfoCache::CancelAll() { void GameInfoCache::FlushBGs() { std::lock_guard lock(mapLock_); - for (auto iter = info_.begin(); iter != info_.end(); iter++) { - std::lock_guard lock(iter->second->lock); - iter->second->pic0.Clear(); - iter->second->pic1.Clear(); - if (!iter->second->sndFileData.empty()) { - iter->second->sndFileData.clear(); - iter->second->sndDataLoaded = false; + for (const auto& iter : info_) { + std::lock_guard lock(iter.second->lock); + iter.second->pic0.Clear(); + iter.second->pic1.Clear(); + if (!iter.second->sndFileData.empty()) { + iter.second->sndFileData.clear(); + iter.second->sndDataLoaded = false; } - iter->second->hasFlags &= ~(GameInfoFlags::PIC0 | GameInfoFlags::PIC1 | GameInfoFlags::SND); + iter.second->hasFlags &= ~(GameInfoFlags::PIC0 | GameInfoFlags::PIC1 | GameInfoFlags::SND); } } diff --git a/UI/GameInfoCache.h b/UI/GameInfoCache.h index 23b9b2d8ec..f3fa0737ae 100644 --- a/UI/GameInfoCache.h +++ b/UI/GameInfoCache.h @@ -78,7 +78,7 @@ public: ~GameInfo(); bool Delete(); // Better be sure what you're doing when calling this. Will move to trash if available on the system, though. - bool DeleteAllSaveData(); + bool DeleteAllSaveData() const; bool CreateLoader(); bool HasFileLoader() const { @@ -90,8 +90,8 @@ public: u64 GetSizeUncompressedInBytes(); // NOTE: More expensive than GetGameSizeOnDiskInBytes(). u64 GetSizeOnDiskInBytes(); - u64 GetGameSavedataSizeInBytes(); // For games - u64 GetInstallDataSizeInBytes(); + u64 GetGameSavedataSizeInBytes() const; // For games + u64 GetInstallDataSizeInBytes() const; // For various kinds of savedata, mainly. // NOTE: This one actually performs I/O directly, not cached. @@ -104,7 +104,7 @@ public: } void FinishPendingTextureLoads(Draw::DrawContext *draw); - std::vector GetSaveDataDirectories(); + std::vector GetSaveDataDirectories() const; std::string GetTitle(); std::string GetDBTitle(); // Falls back to GetTitle if not in the DB.