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`.
This commit is contained in:
mitaclaw
2024-09-21 14:43:21 -07:00
parent 1e5e9219cd
commit 62b2b939b5
20 changed files with 44 additions and 79 deletions

View File

@ -146,8 +146,7 @@ std::optional<Disc> 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<Patch> 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;