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:
committed by
Peter Nelson
parent
876d53282e
commit
059a4b22f7
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user