Reserve vector size when loading station flow stats

This commit is contained in:
Jonathan G Rennison
2023-08-19 17:06:43 +01:00
parent 0f9f1f4280
commit 615c42d357
2 changed files with 6 additions and 0 deletions

View File

@@ -646,6 +646,7 @@ static void Load_STNN()
SlObjectLoadFiltered(&st->goods[i], _filtered_goods_desc);
StationID prev_source = INVALID_STATION;
if (SlXvIsFeaturePresent(XSLFI_FLOW_STAT_FLAGS)) {
st->goods[i].flows.reserve(_num_flows);
for (uint32 j = 0; j < _num_flows; ++j) {
FlowSaveLoad flow;
buffer->CheckBytes(2 + 4);

View File

@@ -493,6 +493,11 @@ public:
return this->flows_index.begin()->first;
}
void reserve(size_t size)
{
this->flows_storage.reserve(size);
}
void SortStorage();
};