summaryrefslogtreecommitdiff
path: root/src/linkgraph
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2016-07-10 12:03:23 +0000
committerfonsinchen <fonsinchen@openttd.org>2016-07-10 12:03:23 +0000
commit022b284064d4ddeb7c2faeda98f791d47dab4353 (patch)
tree5c326161ae3e334fa2ec2d306b39718ae05cdf03 /src/linkgraph
parente2426b22fa0e605834d016d7116d0a8ed2e8223e (diff)
downloadopenttd-022b284064d4ddeb7c2faeda98f791d47dab4353.tar.xz
(svn r27613) -Codechange: Use a flat vector instead of a map in FlowEdgeIterator. (JGR)
Diffstat (limited to 'src/linkgraph')
-rw-r--r--src/linkgraph/mcf.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/linkgraph/mcf.cpp b/src/linkgraph/mcf.cpp
index 10296575c..ecdf792af 100644
--- a/src/linkgraph/mcf.cpp
+++ b/src/linkgraph/mcf.cpp
@@ -136,7 +136,7 @@ private:
LinkGraphJob &job; ///< Link graph job we're working with.
/** 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. */
FlowStat::SharesMap::const_iterator it;
@@ -152,7 +152,11 @@ public:
FlowEdgeIterator(LinkGraphJob &job) : job(job)
{
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;
}
}