mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-23 12:14:11 +01:00
Codefix: prevent inefficient reserve behaviour (#15081)
Same as d3420e6e4c but for Town instead of Industry graph.
This commit is contained in:
@@ -1923,12 +1923,13 @@ struct TownCargoGraphWindow : BaseCargoGraphWindow {
|
||||
const Town *t = Town::Get(this->window_number);
|
||||
|
||||
this->data.clear();
|
||||
this->data.reserve(
|
||||
2 * std::ranges::count_if(t->supplied, &IsValidCargoType, &Town::SuppliedCargo::cargo));
|
||||
|
||||
for (const auto &s : t->supplied) {
|
||||
if (!IsValidCargoType(s.cargo)) continue;
|
||||
const CargoSpec *cs = CargoSpec::Get(s.cargo);
|
||||
|
||||
this->data.reserve(this->data.size() + 2);
|
||||
|
||||
DataSet &produced = this->data.emplace_back();
|
||||
produced.colour = cs->legend_colour;
|
||||
produced.exclude_bit = cs->Index();
|
||||
|
||||
Reference in New Issue
Block a user