Use insert hints for station flow/share map insertion

This commit is contained in:
Jonathan G Rennison
2019-09-23 18:46:43 +01:00
parent 725ff47267
commit 1391f8fc59
2 changed files with 3 additions and 2 deletions

View File

@@ -585,7 +585,7 @@ static void Load_STNN()
if (!IsSavegameVersionBefore(SLV_187)) flow.restricted = (buffer->ReadByte() != 0);
if (fs == nullptr || prev_source != flow.source) {
fs = &(st->goods[i].flows.insert(std::make_pair(flow.source, FlowStat(flow.via, flow.share, flow.restricted))).first->second);
fs = &(st->goods[i].flows.insert(st->goods[i].flows.end(), std::make_pair(flow.source, FlowStat(flow.via, flow.share, flow.restricted)))->second);
} else {
fs->AppendShare(flow.via, flow.share, flow.restricted);
}

View File

@@ -74,7 +74,8 @@ public:
inline void AppendShare(StationID st, uint flow, bool restricted = false)
{
assert(flow > 0);
this->shares[(--this->shares.end())->first + flow] = st;
uint32 key = (--this->shares.end())->first + flow;
this->shares.insert(this->shares.end(), std::make_pair(key, st));
if (!restricted) this->unrestricted += flow;
}