Use insert hints for station flow/share map insertion
This commit is contained in:
@@ -585,7 +585,7 @@ static void Load_STNN()
|
|||||||
if (!IsSavegameVersionBefore(SLV_187)) flow.restricted = (buffer->ReadByte() != 0);
|
if (!IsSavegameVersionBefore(SLV_187)) flow.restricted = (buffer->ReadByte() != 0);
|
||||||
|
|
||||||
if (fs == nullptr || prev_source != flow.source) {
|
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 {
|
} else {
|
||||||
fs->AppendShare(flow.via, flow.share, flow.restricted);
|
fs->AppendShare(flow.via, flow.share, flow.restricted);
|
||||||
}
|
}
|
||||||
|
@@ -74,7 +74,8 @@ public:
|
|||||||
inline void AppendShare(StationID st, uint flow, bool restricted = false)
|
inline void AppendShare(StationID st, uint flow, bool restricted = false)
|
||||||
{
|
{
|
||||||
assert(flow > 0);
|
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;
|
if (!restricted) this->unrestricted += flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user