From 7a8cb149571c6907c04ed60a9ed2d22c52a9f6ce Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 22 Nov 2017 16:03:20 +0300 Subject: [PATCH] Performance fix in CalcCrossMwmTransitions(). --- generator/routing_index_generator.cpp | 6 +++--- routing/cross_mwm_ids.hpp | 1 + routing/cross_mwm_index_graph.hpp | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/generator/routing_index_generator.cpp b/generator/routing_index_generator.cpp index d3435042b9..b16c0ee8d6 100644 --- a/generator/routing_index_generator.cpp +++ b/generator/routing_index_generator.cpp @@ -217,6 +217,9 @@ void CalcCrossMwmTransitions( vector> & transitions) { VehicleMaskBuilder const maskMaker(country, countryParentNameGetterFn); + map featureIdToOsmId; + CHECK(ParseFeatureIdToOsmIdMapping(mappingFile, featureIdToOsmId), + ("Can't parse feature id to osm id mapping. File:", mappingFile)); ForEachFromDat(mwmFile, [&](FeatureType const & f, uint32_t featureId) { VehicleMask const roadMask = maskMaker.CalcRoadMask(f); @@ -228,9 +231,6 @@ void CalcCrossMwmTransitions( if (pointsCount == 0) return; - map featureIdToOsmId; - CHECK(ParseFeatureIdToOsmIdMapping(mappingFile, featureIdToOsmId), - ("Can't parse feature id to osm id mapping. File:", mappingFile)); auto it = featureIdToOsmId.find(featureId); CHECK(it != featureIdToOsmId.end(), ("Can't find osm id for feature id", featureId)); auto const osmId = it->second; diff --git a/routing/cross_mwm_ids.hpp b/routing/cross_mwm_ids.hpp index f912760cb8..1fae058e6c 100644 --- a/routing/cross_mwm_ids.hpp +++ b/routing/cross_mwm_ids.hpp @@ -6,6 +6,7 @@ #include "base/visitor.hpp" #include +#include namespace routing { diff --git a/routing/cross_mwm_index_graph.hpp b/routing/cross_mwm_index_graph.hpp index 9f48b46b10..ffa2f7efcb 100644 --- a/routing/cross_mwm_index_graph.hpp +++ b/routing/cross_mwm_index_graph.hpp @@ -43,8 +43,8 @@ public: /// \note In cross_mwm section transitions are defined by osm ids of theirs features. /// \note This method fills |twins| with all available twins iff all neighboring of mwm of |s| // have cross_mwm section. - void GetTwinsByCrossMwmId(Segment const & s, bool isOutgoing, vector const & neighbors, - vector & twins) + void GetTwinsByCrossMwmId(Segment const & s, bool isOutgoing, std::vector const & neighbors, + std::vector & twins) { auto const & crossMwmId = GetCrossMwmConnectorWithTransitions(s.GetMwmId()).GetCrossMwmId(s); @@ -68,7 +68,7 @@ public: } } - void GetEdgeList(Segment const & s, bool isOutgoing, vector & edges) + void GetEdgeList(Segment const & s, bool isOutgoing, std::vector & edges) { CrossMwmConnector const & c = GetCrossMwmConnectorWithWeights(s.GetMwmId()); c.GetEdgeList(s, isOutgoing, edges);