mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-21 03:12:41 +01:00
Codechange: Use map.emplace() instead of map.insert(std::pair).
This avoids a copy of the pair into the map.
This commit is contained in:
committed by
Peter Nelson
parent
57d7359b1a
commit
ed2db80990
@@ -4810,7 +4810,7 @@ void FlowStatMap::AddFlow(StationID origin, StationID via, uint flow)
|
||||
{
|
||||
FlowStatMap::iterator origin_it = this->find(origin);
|
||||
if (origin_it == this->end()) {
|
||||
this->insert(std::make_pair(origin, FlowStat(via, flow)));
|
||||
this->emplace(origin, FlowStat(via, flow));
|
||||
} else {
|
||||
origin_it->second.ChangeShare(via, flow);
|
||||
assert(!origin_it->second.GetShares()->empty());
|
||||
@@ -4831,7 +4831,7 @@ void FlowStatMap::PassOnFlow(StationID origin, StationID via, uint flow)
|
||||
if (prev_it == this->end()) {
|
||||
FlowStat fs(via, flow);
|
||||
fs.AppendShare(INVALID_STATION, flow);
|
||||
this->insert(std::make_pair(origin, fs));
|
||||
this->emplace(origin, fs);
|
||||
} else {
|
||||
prev_it->second.ChangeShare(via, flow);
|
||||
prev_it->second.ChangeShare(INVALID_STATION, flow);
|
||||
|
||||
Reference in New Issue
Block a user