Codechange: Use range-for to simplify getting first non-zero value.

This reduces indexed array access.
This commit is contained in:
Peter Nelson
2023-11-26 21:30:31 +00:00
committed by Peter Nelson
parent 4181d3c1ff
commit 3f853d8003
3 changed files with 6 additions and 8 deletions

View File

@@ -1373,8 +1373,8 @@ static bool VehicleCargoSorter(const Vehicle * const &a, const Vehicle * const &
for (v = b; v != nullptr; v = v->Next()) diff[v->cargo_type] -= v->cargo_cap;
int r = 0;
for (CargoID i = 0; i < NUM_CARGO; i++) {
r = diff[i];
for (uint d : diff) {
r = d;
if (r != 0) break;
}