mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-19 02:12:37 +01:00
Codechange: Use projection-based std::range::find where possible.
This simplifies matching by class members and avoids wordy lambdas.
This commit is contained in:
committed by
Peter Nelson
parent
876d53282e
commit
059a4b22f7
@@ -1131,7 +1131,7 @@ public:
|
||||
if (g_id != ALL_GROUP && g_id != DEFAULT_GROUP) {
|
||||
const Group *g = Group::Get(g_id);
|
||||
|
||||
auto found = std::find_if(std::begin(this->groups), std::end(this->groups), [g](const auto &item) { return item.group == g; });
|
||||
auto found = std::ranges::find(this->groups, g, &GUIGroupListItem::group);
|
||||
if (found == std::end(this->groups)) {
|
||||
/* The group's branch is maybe collapsed, so try to expand it. */
|
||||
for (auto pg = Group::GetIfValid(g->parent); pg != nullptr; pg = Group::GetIfValid(pg->parent)) {
|
||||
@@ -1140,7 +1140,7 @@ public:
|
||||
this->groups.ForceRebuild();
|
||||
this->BuildGroupList(this->owner);
|
||||
this->group_sb->SetCount(this->groups.size());
|
||||
found = std::find_if(std::begin(this->groups), std::end(this->groups), [g](const auto &item) { return item.group == g; });
|
||||
found = std::ranges::find(this->groups, g, &GUIGroupListItem::group);
|
||||
}
|
||||
if (found != std::end(this->groups)) this->group_sb->ScrollTowards(std::distance(std::begin(this->groups), found));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user