reserve when possible

This commit is contained in:
Moritz Kobitzsch
2016-11-11 14:09:04 +01:00
parent 12ded539aa
commit f88ac989ea
14 changed files with 51 additions and 42 deletions
@@ -56,6 +56,8 @@ Intersection IntersectionGenerator::GetConnectedRoads(const NodeID from_node,
{
Intersection intersection;
const NodeID turn_node = node_based_graph.GetTarget(via_eid);
// reserve enough items (+ the possibly missing u-turn edge)
intersection.reserve(node_based_graph.GetOutDegree(turn_node) + 1);
const NodeID only_restriction_to_node = [&]() {
// If only restrictions refer to invalid ways somewhere far away, we rather ignore the
// restriction than to not route over the intersection at all.
+13 -14
View File
@@ -215,22 +215,21 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
const bool is_through_street =
!target_intersection.empty() && link_data.name_id != EMPTY_NAMEID &&
target_intersection.end() !=
std::find_if(target_intersection.begin() + 1,
target_intersection.end(),
[this, &link_data](const ConnectedRoad &road) {
const auto &road_edge_data =
node_based_graph.GetEdgeData(road.eid);
std::find_if(
target_intersection.begin() + 1,
target_intersection.end(),
[this, &link_data](const ConnectedRoad &road) {
const auto &road_edge_data = node_based_graph.GetEdgeData(road.eid);
const auto same_name =
road_edge_data.name_id != EMPTY_NAMEID &&
!util::guidance::requiresNameAnnounced(
road_edge_data.name_id,
link_data.name_id,
name_table,
street_name_suffix_table);
const auto same_name =
road_edge_data.name_id != EMPTY_NAMEID &&
!util::guidance::requiresNameAnnounced(road_edge_data.name_id,
link_data.name_id,
name_table,
street_name_suffix_table);
return same_name;
});
return same_name;
});
// if the sliproad candidate is a through street, we cannot handle it as a sliproad
if (is_through_street)
@@ -106,6 +106,7 @@ LaneDataVector laneDataFromDescription(TurnLaneDescription turn_lane_description
// transform the map into the lane data vector
LaneDataVector lane_data;
lane_data.reserve(lane_map.size());
for (const auto tag : lane_map)
lane_data.push_back({tag.first, tag.second.first, tag.second.second, false});
@@ -619,6 +619,8 @@ std::pair<LaneDataVector, LaneDataVector> TurnLaneHandler::partitionLaneData(
};
LaneDataVector first, second;
first.reserve(turn_lane_data.size());
second.reserve(turn_lane_data.size());
for (std::size_t lane = 0; lane < turn_lane_data.size(); ++lane)
{
if (matched_at_second[lane])