From 1391f8fc5912b1f97f7a52a952a127c2ffe4511e Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 23 Sep 2019 18:46:43 +0100 Subject: [PATCH] Use insert hints for station flow/share map insertion --- src/saveload/station_sl.cpp | 2 +- src/station_base.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index 3a5d0ec122..8b6248b985 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -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); } diff --git a/src/station_base.h b/src/station_base.h index 26fe5c03b1..418a21cb93 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -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; }