FlowStat: Replace btree_map with flat map which is inlined in small case
Inline storage for size <= 2 Size = 1 is ~90% Size = 2 is ~9% Size >=3 is ~1% and gets a separate allocation
This commit is contained in:
@@ -155,8 +155,8 @@ void LinkGraphJob::FinaliseJob()
|
||||
FlowStat shares(INVALID_STATION, INVALID_STATION, 1);
|
||||
it->SwapShares(shares);
|
||||
it = ge.flows.erase(it);
|
||||
for (FlowStat::SharesMap::const_iterator shares_it(shares.GetShares()->begin());
|
||||
shares_it != shares.GetShares()->end(); ++shares_it) {
|
||||
for (FlowStat::const_iterator shares_it(shares.begin());
|
||||
shares_it != shares.end(); ++shares_it) {
|
||||
RerouteCargo(st, this->Cargo(), shares_it->second, st->index);
|
||||
}
|
||||
}
|
||||
|
@@ -156,10 +156,10 @@ private:
|
||||
std::vector<NodeID> station_to_node;
|
||||
|
||||
/** Current iterator in the shares map. */
|
||||
FlowStat::SharesMap::const_iterator it;
|
||||
FlowStat::const_iterator it;
|
||||
|
||||
/** End of the shares map. */
|
||||
FlowStat::SharesMap::const_iterator end;
|
||||
FlowStat::const_iterator end;
|
||||
public:
|
||||
|
||||
/**
|
||||
@@ -187,11 +187,11 @@ public:
|
||||
const FlowStatMap &flows = this->job[node].Flows();
|
||||
FlowStatMap::const_iterator it = flows.find(this->job[source].Station());
|
||||
if (it != flows.end()) {
|
||||
this->it = it->GetShares()->begin();
|
||||
this->end = it->GetShares()->end();
|
||||
this->it = it->begin();
|
||||
this->end = it->end();
|
||||
} else {
|
||||
this->it = FlowStat::empty_sharesmap.begin();
|
||||
this->end = FlowStat::empty_sharesmap.end();
|
||||
this->it = nullptr;
|
||||
this->end = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user