diff --git a/src/contractor/contractor.cpp b/src/contractor/contractor.cpp index 9624a37fc..6358e5627 100644 --- a/src/contractor/contractor.cpp +++ b/src/contractor/contractor.cpp @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include @@ -37,7 +39,7 @@ namespace std template <> struct hash> { - std::size_t operator()(const std::pair &k) const + std::size_t operator()(const std::pair &k) const noexcept { return static_cast(k.first) ^ (static_cast(k.second) << 12); } @@ -45,7 +47,7 @@ template <> struct hash> template <> struct hash> { - std::size_t operator()(const std::tuple &k) const + std::size_t operator()(const std::tuple &k) const noexcept { std::size_t seed = 0; boost::hash_combine(seed, static_cast(std::get<0>(k))); @@ -265,17 +267,20 @@ std::size_t Contractor::LoadEdgeExpandedGraph( const auto t0 = std::chrono::high_resolution_clock::now(); - const SegmentSpeedSourceMap segment_speed_lookup = [&] { - if (update_edge_weights) - return parse_segment_lookup_from_csv_files(segment_speed_filenames); - return SegmentSpeedSourceMap{}; - }(); + SegmentSpeedSourceMap segment_speed_lookup; + TurnPenaltySourceMap turn_penalty_lookup; - const TurnPenaltySourceMap turn_penalty_lookup = [&] { + const auto parse_segment_speeds = [&] { + if (update_edge_weights) + segment_speed_lookup = parse_segment_lookup_from_csv_files(segment_speed_filenames); + }; + + const auto parse_turn_penalties = [&] { if (update_turn_penalties) - return parse_turn_penalty_lookup_from_csv_files(turn_penalty_filenames); - return TurnPenaltySourceMap{}; - }(); + turn_penalty_lookup = parse_turn_penalty_lookup_from_csv_files(turn_penalty_filenames); + }; + + tbb::parallel_invoke(parse_segment_speeds, parse_turn_penalties); // If we update the edge weights, this file will hold the datasource information for each // segment