Codechange: Use GetVisibleRangeIterators()
in more places. (#12190)
This replaces more first/last index calculation, along with indexed array/vector access, with iterator access instead.
This commit is contained in:
@@ -1704,10 +1704,9 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
|
||||
|
||||
int vehicle_button_x = rtl ? ir.right - profit.width : ir.left;
|
||||
|
||||
uint max = static_cast<uint>(std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size()));
|
||||
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
|
||||
|
||||
const GUIVehicleGroup &vehgroup = this->vehgroups[i];
|
||||
auto [first, last] = this->vscroll->GetVisibleRangeIterators(this->vehgroups);
|
||||
for (auto it = first; it != last; ++it) {
|
||||
const GUIVehicleGroup &vehgroup = *it;
|
||||
|
||||
SetDParam(0, vehgroup.GetDisplayProfitThisYear());
|
||||
SetDParam(1, vehgroup.GetDisplayProfitLastYear());
|
||||
|
Reference in New Issue
Block a user