Merge pull request #13093 from mitaclaw/ranges-modernization-4-projection

Ranges Algorithms Modernization - Projection
This commit is contained in:
JMC47
2025-03-23 15:56:13 -04:00
committed by GitHub
36 changed files with 128 additions and 176 deletions

View File

@ -154,10 +154,9 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
[group_enable_checkbox, group] { group_enable_checkbox->setChecked(group->enabled); });
}
const auto advanced_setting_count = std::count_if(
group->numeric_settings.begin(), group->numeric_settings.end(), [](auto& setting) {
return setting->GetVisibility() == ControllerEmu::SettingVisibility::Advanced;
});
const auto advanced_setting_count =
std::ranges::count(group->numeric_settings, ControllerEmu::SettingVisibility::Advanced,
&ControllerEmu::NumericSettingBase::GetVisibility);
if (advanced_setting_count != 0)
{

View File

@ -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(); }));
}
});

View File

@ -433,13 +433,9 @@ void CodeViewWidget::CalculateBranchIndentation()
// process in order of how much vertical space the drawn arrow would take up
// so shorter arrows go further to the left
const auto priority = [](const CodeViewBranch& b) {
std::ranges::stable_sort(m_branches, {}, [](const CodeViewBranch& b) {
return b.is_link ? 0 : (std::max(b.src_addr, b.dst_addr) - std::min(b.src_addr, b.dst_addr));
};
std::stable_sort(m_branches.begin(), m_branches.end(),
[&priority](const CodeViewBranch& lhs, const CodeViewBranch& rhs) {
return priority(lhs) < priority(rhs);
});
});
// build a 2D lookup table representing the columns and rows the arrow could be drawn in
// and try to place all branch arrows in it as far left as possible