controller: Avoid unnecessary copies in ConfigurationComplete()

Avoids unnecessary 1072 byte copies when querying info about
controllers.
This commit is contained in:
Lioncash 2020-12-07 22:02:56 -05:00
parent 3415890dd5
commit 97dd67ad1c

View file

@ -227,15 +227,14 @@ void Controller::ConfigurationComplete() {
// If enable_single_mode is enabled, player_count is 1 regardless of any other parameters.
// Otherwise, only count connected players from P1-P8.
result_info.player_count =
is_single_mode ? 1
: static_cast<s8>(std::count_if(
players.begin(), players.end() - 2,
[](Settings::PlayerInput player) { return player.connected; }));
is_single_mode
? 1
: static_cast<s8>(std::count_if(players.begin(), players.end() - 2,
[](const auto& player) { return player.connected; }));
result_info.selected_id = HID::Controller_NPad::IndexToNPad(
std::distance(players.begin(),
std::find_if(players.begin(), players.end(),
[](Settings::PlayerInput player) { return player.connected; })));
result_info.selected_id = HID::Controller_NPad::IndexToNPad(std::distance(
players.begin(), std::find_if(players.begin(), players.end(),
[](const auto& player) { return player.connected; })));
result_info.result = 0;