1
0
Fork 0

Codechange: Use ranges to get select server list position.

Replaces a raw loop that uses array indexes.
pull/13316/head
Peter Nelson 2025-01-14 18:22:57 +00:00
parent 95f8fc983b
commit 6c1e5dcdae
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
1 changed files with 5 additions and 6 deletions

View File

@ -325,12 +325,11 @@ protected:
/** Set this->list_pos to match this->server */
void UpdateListPos()
{
this->list_pos = SLP_INVALID;
for (uint i = 0; i != this->servers.size(); i++) {
if (this->servers[i] == this->server) {
this->list_pos = i;
break;
}
auto it = std::ranges::find(this->servers, this->server);
if (it == std::end(this->servers)) {
this->list_pos = SLP_INVALID;
} else {
this->list_pos = static_cast<ServerListPosition>(std::distance(std::begin(this->servers), it));
}
}