Replace loop with std::find_if

This commit is contained in:
Ted John 2020-04-30 01:54:12 +01:00
parent 297fe537b6
commit f642597098
1 changed files with 4 additions and 7 deletions

View File

@ -671,13 +671,10 @@ NetworkConnection* Network::GetPlayerConnection(uint8_t id)
auto player = GetPlayerByID(id); auto player = GetPlayerByID(id);
if (player != nullptr) if (player != nullptr)
{ {
for (auto& connection : client_connection_list) return std::find_if(
{ client_connection_list.begin(), client_connection_list.end(),
if (connection->Player == player) [player](const auto& conn) -> bool { return conn->Player == player; })
{ ->get();
return connection.get();
}
}
} }
return nullptr; return nullptr;
} }