reserve when possible
This commit is contained in:
@@ -818,7 +818,7 @@ void collapseTurnAt(std::vector<RouteStep> &steps,
|
||||
//
|
||||
bool isStaggeredIntersection(const RouteStep &previous, const RouteStep ¤t)
|
||||
{
|
||||
//don't touch roundabouts
|
||||
// don't touch roundabouts
|
||||
if (entersRoundabout(previous.maneuver.instruction) ||
|
||||
entersRoundabout(current.maneuver.instruction))
|
||||
return false;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace util
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
BearingClass::BearingClass() { available_bearings.reserve(10); }
|
||||
|
||||
bool BearingClass::operator==(const BearingClass &other) const
|
||||
{
|
||||
BOOST_ASSERT(std::is_sorted(available_bearings.begin(), available_bearings.end()));
|
||||
|
||||
Reference in New Issue
Block a user