From ab24e9d380e50ba0ecfdfb049b8d19db5cc6362f Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sat, 21 Sep 2024 14:43:21 -0700 Subject: [PATCH] Simplify `std::find_if` with `std::ranges::find` and projections In LabelMap.cpp, the code is currently unused so I was unable to test it. In WiiUtils.cpp, the magic value `1u` was replaced by the constant value `DiscIO::PARTITION_UPDATE`. --- Source/Core/Common/Config/Config.cpp | 5 ++-- Source/Core/Common/Debug/MemoryPatches.cpp | 3 +-- .../Core/ConfigLoaders/GameConfigLoader.cpp | 4 ++-- Source/Core/Core/DSP/DSPTables.cpp | 3 +-- Source/Core/Core/DSP/LabelMap.cpp | 3 +-- Source/Core/Core/HLE/HLE.cpp | 3 +-- Source/Core/Core/IOS/ES/Formats.cpp | 7 +++--- Source/Core/Core/IOS/FS/HostBackend/FS.cpp | 15 ++++-------- Source/Core/Core/IOS/IOS.cpp | 5 ++-- .../Core/Core/IOS/Network/KD/NetKDRequest.cpp | 7 +++--- Source/Core/Core/PowerPC/BreakPoints.cpp | 23 ++++++------------- Source/Core/Core/SysConf.cpp | 6 ++--- Source/Core/Core/WiiUtils.cpp | 8 +++---- Source/Core/DiscIO/DirectoryBlob.cpp | 5 +--- Source/Core/DiscIO/RiivolutionParser.cpp | 6 ++--- Source/Core/DiscIO/WIABlob.cpp | 4 ++-- .../Core/DolphinQt/Config/NewPatchDialog.cpp | 4 ++-- Source/Core/MacUpdater/MacUI.mm | 5 ++-- Source/Core/UICommon/GameFileCache.cpp | 4 +--- Source/Core/VideoCommon/VideoBackendBase.cpp | 4 +--- Source/Core/WinUpdater/Platform.cpp | 3 +-- 21 files changed, 46 insertions(+), 81 deletions(-) diff --git a/Source/Core/Common/Config/Config.cpp b/Source/Core/Common/Config/Config.cpp index 00dbab7bb4..b1e591ddac 100644 --- a/Source/Core/Common/Config/Config.cpp +++ b/Source/Core/Common/Config/Config.cpp @@ -11,6 +11,8 @@ #include #include +#include "Common/Projection.h" + namespace Config { using Layers = std::map>; @@ -168,8 +170,7 @@ const std::string& GetSystemName(System system) std::optional GetSystemFromName(const std::string& name) { - const auto system = std::find_if(system_to_name.begin(), system_to_name.end(), - [&name](const auto& entry) { return entry.second == name; }); + const auto system = std::ranges::find(system_to_name, name, Common::Projection::Value{}); if (system != system_to_name.end()) return system->first; diff --git a/Source/Core/Common/Debug/MemoryPatches.cpp b/Source/Core/Common/Debug/MemoryPatches.cpp index 3dee4d0e03..0becba1dde 100644 --- a/Source/Core/Common/Debug/MemoryPatches.cpp +++ b/Source/Core/Common/Debug/MemoryPatches.cpp @@ -63,8 +63,7 @@ const std::vector& MemoryPatches::GetPatches() const void MemoryPatches::UnsetPatch(const Core::CPUThreadGuard& guard, u32 address) { - const auto it = std::find_if(m_patches.begin(), m_patches.end(), - [address](const auto& patch) { return patch.address == address; }); + const auto it = std::ranges::find(m_patches, address, &MemoryPatch::address); if (it == m_patches.end()) return; diff --git a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp index 020e8d6da3..379b561cc5 100644 --- a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp @@ -22,6 +22,7 @@ #include "Common/IniFile.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" +#include "Common/Projection.h" #include "Common/StringUtil.h" #include "Core/Config/MainSettings.h" @@ -147,8 +148,7 @@ static Location MapINIToRealLocation(const std::string& section, const std::stri static std::pair GetINILocationFromConfig(const Location& location) { static const INIToLocationMap& ini_to_location = GetINIToLocationMap(); - const auto it = std::find_if(ini_to_location.begin(), ini_to_location.end(), - [&location](const auto& entry) { return entry.second == location; }); + const auto it = std::ranges::find(ini_to_location, location, Common::Projection::Value{}); if (it != ini_to_location.end()) return it->first; diff --git a/Source/Core/Core/DSP/DSPTables.cpp b/Source/Core/Core/DSP/DSPTables.cpp index 175b7601c7..21502fe0c8 100644 --- a/Source/Core/Core/DSP/DSPTables.cpp +++ b/Source/Core/Core/DSP/DSPTables.cpp @@ -525,8 +525,7 @@ std::array s_ext_op_table; template auto FindByName(std::string_view name, const std::array& data) { - return std::find_if(data.cbegin(), data.cend(), - [&name](const auto& info) { return name == info.name; }); + return std::ranges::find(data, name, &DSPOPCTemplate::name); } } // Anonymous namespace diff --git a/Source/Core/Core/DSP/LabelMap.cpp b/Source/Core/Core/DSP/LabelMap.cpp index 19a7a0ae77..0e4f7d39ed 100644 --- a/Source/Core/Core/DSP/LabelMap.cpp +++ b/Source/Core/Core/DSP/LabelMap.cpp @@ -63,8 +63,7 @@ bool LabelMap::RegisterLabel(std::string label, u16 lval, LabelType type) void LabelMap::DeleteLabel(std::string_view label) { - const auto iter = std::find_if(labels.cbegin(), labels.cend(), - [&label](const auto& entry) { return entry.name == label; }); + const auto iter = std::ranges::find(labels, label, &Label::name); if (iter == labels.cend()) return; diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp index 66d0960821..a0ca859371 100644 --- a/Source/Core/Core/HLE/HLE.cpp +++ b/Source/Core/Core/HLE/HLE.cpp @@ -240,8 +240,7 @@ bool IsEnabled(HookFlag flag, PowerPC::CoreMode mode) u32 UnPatch(Core::System& system, std::string_view patch_name) { - const auto patch = std::find_if(std::begin(os_patches), std::end(os_patches), - [&](const Hook& p) { return patch_name == p.name; }); + const auto patch = std::ranges::find(os_patches, patch_name, &Hook::name); if (patch == std::end(os_patches)) return 0; diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index 80715f6a58..29f68adcf6 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -22,6 +22,7 @@ #include "Common/Crypto/SHA1.h" #include "Common/Logging/Log.h" #include "Common/NandPaths.h" +#include "Common/Projection.h" #include "Common/StringUtil.h" #include "Common/Swap.h" #include "Core/CommonTitles.h" @@ -571,8 +572,7 @@ SharedContentMap::~SharedContentMap() = default; std::optional SharedContentMap::GetFilenameFromSHA1(const std::array& sha1) const { - const auto it = std::find_if(m_entries.begin(), m_entries.end(), - [&sha1](const auto& entry) { return entry.sha1 == sha1; }); + const auto it = std::ranges::find(m_entries, sha1, &Entry::sha1); if (it == m_entries.end()) return {}; @@ -670,8 +670,7 @@ UIDSys::UIDSys(HLE::FSCore& fs_core) : m_fs{fs_core.GetFS()} u32 UIDSys::GetUIDFromTitle(u64 title_id) const { - const auto it = std::find_if(m_entries.begin(), m_entries.end(), - [title_id](const auto& entry) { return entry.second == title_id; }); + const auto it = std::ranges::find(m_entries, title_id, Common::Projection::Value{}); return (it == m_entries.end()) ? 0 : it->first; } diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp index c26cb7ee74..468b68bebf 100644 --- a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp +++ b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp @@ -86,11 +86,6 @@ auto GetMetadataFields(T& obj) return std::tie(obj.uid, obj.gid, obj.is_file, obj.modes, obj.attribute); } -auto GetNamePredicate(const std::string& name) -{ - return [&name](const auto& entry) { return entry.name == name; }; -} - // Convert the host directory entries into ones that can be exposed to the emulated system. static u64 FixupDirectoryEntries(File::FSTEntry* dir, bool is_root) { @@ -254,8 +249,7 @@ HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string& for (const std::string& component : SplitString(std::string(path.substr(1)), '/')) { complete_path += '/' + component; - const auto next = - std::find_if(entry->children.begin(), entry->children.end(), GetNamePredicate(component)); + const auto next = std::ranges::find(entry->children, component, &FstEntry::name); if (next != entry->children.end()) { entry = &*next; @@ -552,8 +546,7 @@ ResultCode HostFileSystem::Delete(Uid uid, Gid gid, const std::string& path) else return ResultCode::InUse; - const auto it = std::find_if(parent->children.begin(), parent->children.end(), - GetNamePredicate(split_path.file_name)); + const auto it = std::ranges::find(parent->children, split_path.file_name, &FstEntry::name); if (it != parent->children.end()) parent->children.erase(it); SaveFst(); @@ -642,8 +635,8 @@ ResultCode HostFileSystem::Rename(Uid uid, Gid gid, const std::string& old_path, new_entry->name = split_new_path.file_name; // Finally, remove the child from the old parent and move it to the new parent. - const auto it = std::find_if(old_parent->children.begin(), old_parent->children.end(), - GetNamePredicate(split_old_path.file_name)); + const auto it = + std::ranges::find(old_parent->children, split_old_path.file_name, &FstEntry::name); if (it != old_parent->children.end()) { new_entry->data = it->data; diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index fbea8dd9d7..905cd459fa 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -105,9 +105,8 @@ constexpr u32 PLACEHOLDER = 0xDEADBEEF; static bool SetupMemory(Memory::MemoryManager& memory, u64 ios_title_id, MemorySetupType setup_type) { - auto target_imv = std::find_if( - GetMemoryValues().begin(), GetMemoryValues().end(), - [&](const MemoryValues& imv) { return imv.ios_number == (ios_title_id & 0xffff); }); + auto target_imv = std::ranges::find(GetMemoryValues(), static_cast(ios_title_id & 0xffff), + &MemoryValues::ios_number); if (target_imv == GetMemoryValues().end()) { diff --git a/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp b/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp index ddc99fa4c5..1c60649102 100644 --- a/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp +++ b/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp @@ -16,6 +16,7 @@ #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/NandPaths.h" +#include "Common/Projection.h" #include "Common/SettingsHandler.h" #include "Common/StringUtil.h" @@ -62,8 +63,7 @@ u8 GetAreaCode(std::string_view area) {"CHN", 6}, }}; - const auto entry_pos = std::find_if(regions.cbegin(), regions.cend(), - [&area](const auto& entry) { return entry.first == area; }); + const auto entry_pos = std::ranges::find(regions, area, Common::Projection::Key{}); if (entry_pos != regions.end()) return entry_pos->second; @@ -79,8 +79,7 @@ HardwareModel GetHardwareModel(std::string_view model) {"RVD", HardwareModel::RVD}, }}; - const auto entry_pos = std::find_if(models.cbegin(), models.cend(), - [&model](const auto& entry) { return entry.first == model; }); + const auto entry_pos = std::ranges::find(models, model, Common::Projection::Key{}); if (entry_pos != models.cend()) return entry_pos->second; diff --git a/Source/Core/Core/PowerPC/BreakPoints.cpp b/Source/Core/Core/PowerPC/BreakPoints.cpp index 19ceac7b3f..4f0226d791 100644 --- a/Source/Core/Core/PowerPC/BreakPoints.cpp +++ b/Source/Core/Core/PowerPC/BreakPoints.cpp @@ -49,8 +49,7 @@ const TBreakPoint* BreakPoints::GetBreakpoint(u32 address) const const TBreakPoint* BreakPoints::GetRegularBreakpoint(u32 address) const { - auto bp = std::find_if(m_breakpoints.begin(), m_breakpoints.end(), - [address](const auto& bp_) { return bp_.address == address; }); + auto bp = std::ranges::find(m_breakpoints, address, &TBreakPoint::address); if (bp == m_breakpoints.end()) return nullptr; @@ -127,8 +126,7 @@ void BreakPoints::Add(u32 address, bool break_on_hit, bool log_on_hit, { // Check for existing breakpoint, and overwrite with new info. // This is assuming we usually want the new breakpoint over an old one. - auto iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(), - [address](const auto& bp) { return bp.address == address; }); + auto iter = std::ranges::find(m_breakpoints, address, &TBreakPoint::address); TBreakPoint bp; // breakpoint settings bp.is_enabled = true; @@ -176,8 +174,7 @@ bool BreakPoints::ToggleBreakPoint(u32 address) bool BreakPoints::ToggleEnable(u32 address) { - auto iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(), - [address](const auto& bp) { return bp.address == address; }); + auto iter = std::ranges::find(m_breakpoints, address, &TBreakPoint::address); if (iter == m_breakpoints.end()) return false; @@ -188,8 +185,7 @@ bool BreakPoints::ToggleEnable(u32 address) bool BreakPoints::Remove(u32 address) { - const auto iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(), - [address](const auto& bp) { return bp.address == address; }); + const auto iter = std::ranges::find(m_breakpoints, address, &TBreakPoint::address); if (iter == m_breakpoints.cend()) return false; @@ -293,9 +289,7 @@ void MemChecks::Add(TMemCheck memory_check) // Check for existing breakpoint, and overwrite with new info. // This is assuming we usually want the new breakpoint over an old one. const u32 address = memory_check.start_address; - auto old_mem_check = - std::find_if(m_mem_checks.begin(), m_mem_checks.end(), - [address](const auto& check) { return check.start_address == address; }); + auto old_mem_check = std::ranges::find(m_mem_checks, address, &TMemCheck::start_address); if (old_mem_check != m_mem_checks.end()) { memory_check.is_enabled = old_mem_check->is_enabled; // Preserve enabled status @@ -315,8 +309,7 @@ void MemChecks::Add(TMemCheck memory_check) bool MemChecks::ToggleEnable(u32 address) { - auto iter = std::find_if(m_mem_checks.begin(), m_mem_checks.end(), - [address](const auto& bp) { return bp.start_address == address; }); + auto iter = std::ranges::find(m_mem_checks, address, &TMemCheck::start_address); if (iter == m_mem_checks.end()) return false; @@ -327,9 +320,7 @@ bool MemChecks::ToggleEnable(u32 address) bool MemChecks::Remove(u32 address) { - const auto iter = - std::find_if(m_mem_checks.cbegin(), m_mem_checks.cend(), - [address](const auto& check) { return check.start_address == address; }); + const auto iter = std::ranges::find(m_mem_checks, address, &TMemCheck::start_address); if (iter == m_mem_checks.cend()) return false; diff --git a/Source/Core/Core/SysConf.cpp b/Source/Core/Core/SysConf.cpp index bc5f133f69..bef12fe014 100644 --- a/Source/Core/Core/SysConf.cpp +++ b/Source/Core/Core/SysConf.cpp @@ -228,15 +228,13 @@ SysConf::Entry& SysConf::AddEntry(Entry&& entry) SysConf::Entry* SysConf::GetEntry(std::string_view key) { - const auto iterator = std::find_if(m_entries.begin(), m_entries.end(), - [&key](const auto& entry) { return entry.name == key; }); + const auto iterator = std::ranges::find(m_entries, key, &Entry::name); return iterator != m_entries.end() ? &*iterator : nullptr; } const SysConf::Entry* SysConf::GetEntry(std::string_view key) const { - const auto iterator = std::find_if(m_entries.begin(), m_entries.end(), - [&key](const auto& entry) { return entry.name == key; }); + const auto iterator = std::ranges::find(m_entries, key, &Entry::name); return iterator != m_entries.end() ? &*iterator : nullptr; } diff --git a/Source/Core/Core/WiiUtils.cpp b/Source/Core/Core/WiiUtils.cpp index 054f3cf0c1..b93c31ecc2 100644 --- a/Source/Core/Core/WiiUtils.cpp +++ b/Source/Core/Core/WiiUtils.cpp @@ -42,6 +42,7 @@ #include "Core/SysConf.h" #include "Core/System.h" #include "DiscIO/DiscExtractor.h" +#include "DiscIO/DiscUtils.h" #include "DiscIO/Enums.h" #include "DiscIO/Filesystem.h" #include "DiscIO/VolumeDisc.h" @@ -749,10 +750,9 @@ UpdateResult DiscSystemUpdater::DoDiscUpdate() return UpdateResult::RegionMismatch; const auto partitions = m_volume->GetPartitions(); - const auto update_partition = - std::find_if(partitions.cbegin(), partitions.cend(), [&](const DiscIO::Partition& partition) { - return m_volume->GetPartitionType(partition) == 1u; - }); + const auto update_partition = std::ranges::find( + partitions, DiscIO::PARTITION_UPDATE, + [&](const DiscIO::Partition& partition) { return m_volume->GetPartitionType(partition); }); if (update_partition == partitions.cend()) { diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp index 130175f1ca..5d080afe1d 100644 --- a/Source/Core/DiscIO/DirectoryBlob.cpp +++ b/Source/Core/DiscIO/DirectoryBlob.cpp @@ -862,10 +862,7 @@ static std::vector ExtractNodeToVector(std::vector* nodes, v DirectoryBlobReader* blob) { std::vector data; - const auto it = - std::find_if(nodes->begin(), nodes->end(), [&userdata](const FSTBuilderNode& node) { - return node.m_user_data == userdata; - }); + const auto it = std::ranges::find(*nodes, userdata, &FSTBuilderNode::m_user_data); if (it == nodes->end() || !it->IsFile()) return data; diff --git a/Source/Core/DiscIO/RiivolutionParser.cpp b/Source/Core/DiscIO/RiivolutionParser.cpp index f120335f56..471813f198 100644 --- a/Source/Core/DiscIO/RiivolutionParser.cpp +++ b/Source/Core/DiscIO/RiivolutionParser.cpp @@ -146,8 +146,7 @@ std::optional ParseString(std::string_view xml, std::string xml_path) const std::string macro_id = macro_node.attribute("id").as_string(); for (auto& section : disc.m_sections) { - auto option_to_clone = std::find_if(section.m_options.begin(), section.m_options.end(), - [&](const Option& o) { return o.m_id == macro_id; }); + auto option_to_clone = std::ranges::find(section.m_options, macro_id, &Option::m_id); if (option_to_clone == section.m_options.end()) continue; @@ -305,8 +304,7 @@ std::vector Disc::GeneratePatches(const std::string& game_id) const const Choice& choice = option.m_choices[selected - 1]; for (const auto& patch_ref : choice.m_patch_references) { - const auto patch = std::find_if(m_patches.begin(), m_patches.end(), - [&](const Patch& p) { return patch_ref.m_id == p.m_id; }); + const auto patch = std::ranges::find(m_patches, patch_ref.m_id, &Patch::m_id); if (patch == m_patches.end()) continue; diff --git a/Source/Core/DiscIO/WIABlob.cpp b/Source/Core/DiscIO/WIABlob.cpp index ec39245884..c59802c947 100644 --- a/Source/Core/DiscIO/WIABlob.cpp +++ b/Source/Core/DiscIO/WIABlob.cpp @@ -1372,8 +1372,8 @@ WIARVZFileReader::ProcessAndCompress(CompressThreadState* state, CompressPa TryReuse(reusable_groups, reusable_groups_mutex, &entry); if (!entry.reused_group && reuse_id) { - const auto it = std::find_if(output_entries.begin(), output_entries.begin() + i, - [reuse_id](const auto& e) { return e.reuse_id == reuse_id; }); + const auto it = std::ranges::find(output_entries.begin(), output_entries.begin() + i, + reuse_id, &OutputParametersEntry::reuse_id); if (it != output_entries.begin() + i) entry.reused_group = it->reused_group; } diff --git a/Source/Core/DolphinQt/Config/NewPatchDialog.cpp b/Source/Core/DolphinQt/Config/NewPatchDialog.cpp index b3bc86849b..7ac0d7ede2 100644 --- a/Source/Core/DolphinQt/Config/NewPatchDialog.cpp +++ b/Source/Core/DolphinQt/Config/NewPatchDialog.cpp @@ -181,8 +181,8 @@ QGroupBox* NewPatchDialog::CreateEntry(const PatchEngine::PatchEntry& entry) m_entry_layout->removeWidget(box); box->deleteLater(); - m_entries.erase(std::find_if(m_entries.begin(), m_entries.end(), - [new_entry](const auto& e) { return e.get() == new_entry; })); + m_entries.erase( + std::ranges::find(m_entries, new_entry, [](const auto& e) { return e.get(); })); } }); diff --git a/Source/Core/MacUpdater/MacUI.mm b/Source/Core/MacUpdater/MacUI.mm index 55564805fe..b52da3182f 100644 --- a/Source/Core/MacUpdater/MacUI.mm +++ b/Source/Core/MacUpdater/MacUI.mm @@ -148,9 +148,8 @@ bool UI::IsTestMode() bool Platform::VersionCheck(const std::vector& to_update, const std::string& install_base_path, const std::string& temp_dir) { - const auto op_it = std::find_if(to_update.cbegin(), to_update.cend(), [&](const auto& op) { - return op.filename == "Dolphin.app/Contents/Info.plist"; - }); + const auto op_it = std::ranges::find(to_update, "Dolphin.app/Contents/Info.plist", + &TodoList::UpdateOp::filename); if (op_it == to_update.cend()) return true; diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp index d5b970d29c..90dd0c63fc 100644 --- a/Source/Core/UICommon/GameFileCache.cpp +++ b/Source/Core/UICommon/GameFileCache.cpp @@ -65,9 +65,7 @@ void GameFileCache::Clear(DeleteOnDisk delete_on_disk) std::shared_ptr GameFileCache::AddOrGet(const std::string& path, bool* cache_changed) { - auto it = std::find_if( - m_cached_files.begin(), m_cached_files.end(), - [&path](const std::shared_ptr& file) { return file->GetFilePath() == path; }); + auto it = std::ranges::find(m_cached_files, path, &GameFile::GetFilePath); const bool found = it != m_cached_files.cend(); if (!found) { diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index e8f9f91b41..0234496e3f 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -278,9 +278,7 @@ void VideoBackendBase::ActivateBackend(const std::string& name) g_video_backend = GetDefaultVideoBackend(); const auto& backends = GetAvailableBackends(); - const auto iter = std::find_if(backends.begin(), backends.end(), [&name](const auto& backend) { - return name == backend->GetName(); - }); + const auto iter = std::ranges::find(backends, name, &VideoBackendBase::GetName); if (iter == backends.end()) return; diff --git a/Source/Core/WinUpdater/Platform.cpp b/Source/Core/WinUpdater/Platform.cpp index bc8ccb843e..bca74cddb5 100644 --- a/Source/Core/WinUpdater/Platform.cpp +++ b/Source/Core/WinUpdater/Platform.cpp @@ -250,8 +250,7 @@ std::optional InitBuildInfos(const std::vector& const std::string& install_base_path, const std::string& temp_dir) { - const auto op_it = std::find_if(to_update.cbegin(), to_update.cend(), - [&](const auto& op) { return op.filename == "build_info.txt"; }); + const auto op_it = std::ranges::find(to_update, "build_info.txt", &TodoList::UpdateOp::filename); if (op_it == to_update.cend()) return {};