1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-19 10:22:39 +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

@@ -1624,9 +1624,7 @@ protected:
* because this is the one the player interested in, and that way it is not hidden in the 'n' more cargos */
const CargoID cid = this->produced_cargo_filter_criteria;
if (cid != CargoFilterCriteria::CF_ANY && cid != CargoFilterCriteria::CF_NONE) {
auto filtered_ci = std::find_if(cargos.begin(), cargos.end(), [cid](const CargoInfo &ci) -> bool {
return ci.cargo_id == cid;
});
auto filtered_ci = std::ranges::find(cargos, cid, &CargoInfo::cargo_id);
if (filtered_ci != cargos.end()) {
std::rotate(cargos.begin(), filtered_ci, filtered_ci + 1);
}