check for empty on string_ref, rather than string itself

This commit is contained in:
karenzshea 2017-12-01 11:36:03 +01:00 committed by Patrick Niklaus
parent 89080fb2b0
commit 4166b1ebbf
6 changed files with 26 additions and 29 deletions

View File

@ -77,8 +77,8 @@ TurnType::Enum IntersectionHandler::findBasicTurnType(const EdgeID via_edge,
const auto &out_name_id = const auto &out_name_id =
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(road.eid).annotation_data) node_data_container.GetAnnotation(node_based_graph.GetEdgeData(road.eid).annotation_data)
.name_id; .name_id;
const auto &in_name_empty = name_table.GetNameForID(in_name_id).to_string().empty(); const auto &in_name_empty = name_table.GetNameForID(in_name_id).empty();
const auto &out_name_empty = name_table.GetNameForID(out_name_id).to_string().empty(); const auto &out_name_empty = name_table.GetNameForID(out_name_id).empty();
const auto same_name = !util::guidance::requiresNameAnnounced( const auto same_name = !util::guidance::requiresNameAnnounced(
in_name_id, out_name_id, name_table, street_name_suffix_table); in_name_id, out_name_id, name_table, street_name_suffix_table);

View File

@ -40,8 +40,8 @@ inline auto makeCheckRoadForName(const NameID name_id,
.name_id; .name_id;
if (name_id == EMPTY_NAMEID || road_name_id == EMPTY_NAMEID) if (name_id == EMPTY_NAMEID || road_name_id == EMPTY_NAMEID)
return true; return true;
const auto road_name_empty = name_table.GetNameForID(road_name_id).to_string().empty(); const auto road_name_empty = name_table.GetNameForID(road_name_id).empty();
const auto in_name_empty = name_table.GetNameForID(name_id).to_string().empty(); const auto in_name_empty = name_table.GetNameForID(name_id).empty();
if (in_name_empty || road_name_empty) if (in_name_empty || road_name_empty)
return true; return true;
const auto requires_announcement = const auto requires_announcement =
@ -480,9 +480,8 @@ bool MergableRoadDetector::IsTrafficIsland(const NodeID intersection_node,
.name_id; .name_id;
if (road_name_id == EMPTY_NAMEID) if (road_name_id == EMPTY_NAMEID)
return false; return false;
const auto &road_name_empty = name_table.GetNameForID(road_name_id).to_string().empty(); const auto &road_name_empty = name_table.GetNameForID(road_name_id).empty();
const auto &required_name_empty = const auto &required_name_empty = name_table.GetNameForID(required_name_id).empty();
name_table.GetNameForID(required_name_id).to_string().empty();
if (required_name_empty && road_name_empty) if (required_name_empty && road_name_empty)
return false; return false;
return !util::guidance::requiresNameAnnounced( return !util::guidance::requiresNameAnnounced(

View File

@ -386,14 +386,14 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
// //
// 7 1 // 7 1
// 0 // 0
const auto &first_intersection_name = const auto &first_intersection_name_empty =
name_table.GetNameForID(first_intersection_data.name_id).to_string(); name_table.GetNameForID(first_intersection_data.name_id).empty();
const auto &second_intersection_name = const auto &second_intersection_name_empty =
name_table.GetNameForID(second_intersection_data.name_id).to_string(); name_table.GetNameForID(second_intersection_data.name_id).empty();
if (intersection[1].entry_allowed) if (intersection[1].entry_allowed)
{ {
if (isMotorwayClass(intersection[1].eid, node_based_graph) && if (isMotorwayClass(intersection[1].eid, node_based_graph) &&
!second_intersection_name.empty() && !first_intersection_name.empty() && !second_intersection_name_empty && !first_intersection_name_empty &&
first_second_same_name) first_second_same_name)
{ {
// circular order indicates a merge to the left (0-3 onto 4 // circular order indicates a merge to the left (0-3 onto 4
@ -418,7 +418,7 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
{ {
BOOST_ASSERT(intersection[2].entry_allowed); BOOST_ASSERT(intersection[2].entry_allowed);
if (isMotorwayClass(intersection[2].eid, node_based_graph) && if (isMotorwayClass(intersection[2].eid, node_based_graph) &&
!second_intersection_name.empty() && !first_intersection_name.empty() && !second_intersection_name_empty && !first_intersection_name_empty &&
first_second_same_name) first_second_same_name)
{ {
// circular order (5-0) onto 4 // circular order (5-0) onto 4

View File

@ -297,8 +297,9 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
if (edge_data.name_id != EMPTY_NAMEID) if (edge_data.name_id != EMPTY_NAMEID)
{ {
const auto &edge_name = name_table.GetNameForID(edge_data.name_id).to_string(); const auto &edge_name_empty =
if (!edge_name.empty()) name_table.GetNameForID(edge_data.name_id).empty();
if (!edge_name_empty)
{ {
const auto announce = [&](unsigned id) { const auto announce = [&](unsigned id) {

View File

@ -475,9 +475,7 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
// Name mismatch: check roads at `c` and `d` for same name // Name mismatch: check roads at `c` and `d` for same name
const auto name_mismatch = [&](const NameID road_name_id) { const auto name_mismatch = [&](const NameID road_name_id) {
const auto unnamed = const auto unnamed =
road_name_id == EMPTY_NAMEID road_name_id == EMPTY_NAMEID || name_table.GetNameForID(road_name_id).empty();
? true
: name_table.GetNameForID(road_name_id).to_string().empty();
return unnamed || return unnamed ||
util::guidance::requiresNameAnnounced(road_name_id, // util::guidance::requiresNameAnnounced(road_name_id, //
@ -502,17 +500,18 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
node_data_container node_data_container
.GetAnnotation(node_based_graph.GetEdgeData(main_road.eid).annotation_data) .GetAnnotation(node_based_graph.GetEdgeData(main_road.eid).annotation_data)
.name_id; .name_id;
const auto main_road_name_empty = main_road_name_id == EMPTY_NAMEID ||
name_table.GetNameForID(main_road_name_id).empty();
const auto &sliproad_annotation = const auto &sliproad_annotation =
node_data_container.GetAnnotation(sliproad_edge_data.annotation_data); node_data_container.GetAnnotation(sliproad_edge_data.annotation_data);
const auto &sliproad_name_empty = const auto sliproad_name_empty =
sliproad_annotation.name_id == EMPTY_NAMEID sliproad_annotation.name_id == EMPTY_NAMEID ||
? true name_table.GetNameForID(sliproad_annotation.name_id).empty();
: name_table.GetNameForID(sliproad_annotation.name_id).to_string().empty(); const auto candidate_road_name_empty =
const auto &main_road_name = name_table.GetNameForID(main_road_name_id).to_string(); candidate_data.name_id == EMPTY_NAMEID ||
const auto &candidate_road_name = name_table.GetNameForID(candidate_data.name_id).empty();
name_table.GetNameForID(candidate_data.name_id).to_string();
if (!sliproad_edge_data.flags.road_classification.IsLinkClass() && if (!sliproad_edge_data.flags.road_classification.IsLinkClass() &&
!sliproad_name_empty && !main_road_name.empty() && !candidate_road_name.empty() && !sliproad_name_empty && !main_road_name_empty && !candidate_road_name_empty &&
util::guidance::requiresNameAnnounced(main_road_name_id, util::guidance::requiresNameAnnounced(main_road_name_id,
sliproad_annotation.name_id, sliproad_annotation.name_id,
name_table, name_table,

View File

@ -200,9 +200,7 @@ bool TurnHandler::isObviousOfTwo(const EdgeID via_edge,
const bool turn_is_perfectly_straight = const bool turn_is_perfectly_straight =
angularDeviation(road.angle, STRAIGHT_ANGLE) < std::numeric_limits<double>::epsilon(); angularDeviation(road.angle, STRAIGHT_ANGLE) < std::numeric_limits<double>::epsilon();
const auto &via_name_empty = const auto &via_name_empty =
via_data.name_id == EMPTY_NAMEID via_data.name_id == EMPTY_NAMEID || name_table.GetNameForID(via_data.name_id).empty();
? true
: name_table.GetNameForID(via_data.name_id).to_string().empty();
if (!via_name_empty) if (!via_name_empty)
{ {
const auto same_name = !util::guidance::requiresNameAnnounced( const auto same_name = !util::guidance::requiresNameAnnounced(