1
0
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:
Peter Nelson
2024-11-10 10:56:37 +00:00
committed by Peter Nelson
parent 876d53282e
commit 059a4b22f7
16 changed files with 31 additions and 44 deletions

View File

@@ -403,7 +403,7 @@ void TextfileWindow::NavigateHistory(int delta)
switch (ClassifyHyperlink(link.destination, this->trusted)) {
case HyperlinkType::Internal:
{
auto it = std::find_if(this->link_anchors.cbegin(), this->link_anchors.cend(), [&](const Hyperlink &other) { return link.destination == other.destination; });
auto it = std::ranges::find(this->link_anchors, link.destination, &Hyperlink::destination);
if (it != this->link_anchors.cend()) {
this->AppendHistory(this->filepath);
this->ScrollToLine(it->line);
@@ -484,7 +484,7 @@ void TextfileWindow::NavigateToFile(std::string newfile, size_t line)
if (anchor.empty() || line != 0) {
this->ScrollToLine(line);
} else {
auto anchor_dest = std::find_if(this->link_anchors.cbegin(), this->link_anchors.cend(), [&](const Hyperlink &other) { return anchor == other.destination; });
auto anchor_dest = std::ranges::find(this->link_anchors, anchor, &Hyperlink::destination);
if (anchor_dest != this->link_anchors.cend()) {
this->ScrollToLine(anchor_dest->line);
this->UpdateHistoryScrollpos();