mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-03 19:42:45 +01:00
Simplify std::count_if
with std::ranges::count
and projections
This commit is contained in:
parent
ab24e9d380
commit
3536e287e0
@ -2407,22 +2407,14 @@ bool NetPlayClient::IsFirstInGamePad(int ingame_pad) const
|
||||
[](auto mapping) { return mapping > 0; });
|
||||
}
|
||||
|
||||
static int CountLocalPads(const PadMappingArray& pad_map, const PlayerId& local_player_pid)
|
||||
{
|
||||
return static_cast<int>(
|
||||
std::count_if(pad_map.begin(), pad_map.end(), [&local_player_pid](const auto& mapping) {
|
||||
return mapping == local_player_pid;
|
||||
}));
|
||||
}
|
||||
|
||||
int NetPlayClient::NumLocalPads() const
|
||||
{
|
||||
return CountLocalPads(m_pad_map, m_local_player->pid);
|
||||
return std::ranges::count(m_pad_map, m_local_player->pid);
|
||||
}
|
||||
|
||||
int NetPlayClient::NumLocalWiimotes() const
|
||||
{
|
||||
return CountLocalPads(m_wiimote_map, m_local_player->pid);
|
||||
return std::ranges::count(m_wiimote_map, m_local_player->pid);
|
||||
}
|
||||
|
||||
static int InGameToLocal(int ingame_pad, const PadMappingArray& pad_map, PlayerId local_player_pid)
|
||||
|
@ -155,10 +155,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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user