mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
Use a flat vector instead of a map in FlowEdgeIterator.
This reduced the cost of Dijkstra<CapacityAnnotation> by approx. 25%, in a test profiling.
This commit is contained in:
parent
a3768d3a29
commit
0fb79a8f15
@ -136,7 +136,7 @@ private:
|
|||||||
LinkGraphJob &job; ///< Link graph job we're working with.
|
LinkGraphJob &job; ///< Link graph job we're working with.
|
||||||
|
|
||||||
/** Lookup table for getting NodeIDs from StationIDs. */
|
/** Lookup table for getting NodeIDs from StationIDs. */
|
||||||
std::map<StationID, NodeID> station_to_node;
|
std::vector<NodeID> station_to_node;
|
||||||
|
|
||||||
/** Current iterator in the shares map. */
|
/** Current iterator in the shares map. */
|
||||||
FlowStat::SharesMap::const_iterator it;
|
FlowStat::SharesMap::const_iterator it;
|
||||||
@ -152,7 +152,11 @@ public:
|
|||||||
FlowEdgeIterator(LinkGraphJob &job) : job(job)
|
FlowEdgeIterator(LinkGraphJob &job) : job(job)
|
||||||
{
|
{
|
||||||
for (NodeID i = 0; i < job.Size(); ++i) {
|
for (NodeID i = 0; i < job.Size(); ++i) {
|
||||||
this->station_to_node[job[i].Station()] = i;
|
StationID st = job[i].Station();
|
||||||
|
if (st >= this->station_to_node.size()) {
|
||||||
|
this->station_to_node.resize(st + 1);
|
||||||
|
}
|
||||||
|
this->station_to_node[st] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user