Enable readability-container-contains clang-tidy check (#6909)

This commit is contained in:
Siarhei Fedartsou
2024-05-27 08:33:26 +02:00
committed by GitHub
parent 1a6f4c44e7
commit 9aaab7a53f
14 changed files with 33 additions and 33 deletions
+4 -4
View File
@@ -125,9 +125,9 @@ std::vector<RouteStep> anticipateLaneChange(std::vector<RouteStep> steps,
if (previous_is_straight)
{
if (isLeftTurn(current_inst) || is_straight_left.count(&current) > 0)
if (isLeftTurn(current_inst) || is_straight_left.contains(&current))
is_straight_left.insert(&previous);
else if (isRightTurn(current_inst) || is_straight_right.count(&current) > 0)
else if (isRightTurn(current_inst) || is_straight_right.contains(&current))
is_straight_right.insert(&previous);
}
@@ -190,9 +190,9 @@ std::vector<RouteStep> anticipateLaneChange(std::vector<RouteStep> steps,
//
// coming from right, going to left (in direction of way) -> handle as left turn
if (is_straight_left.count(&current) > 0)
if (is_straight_left.contains(&current))
anticipate_for_left_turn();
else if (is_straight_right.count(&current) > 0)
else if (is_straight_right.contains(&current))
anticipate_for_right_turn();
else // FIXME: right-sided driving
anticipate_for_right_turn();
@@ -248,7 +248,7 @@ filterViaCandidatesByViaNotOnPath(const WeightedViaNodePackedPath &path, RandIt
for (const auto &edge : path.path)
nodes.insert(std::get<1>(edge));
const auto via_on_path = [&](const auto via) { return nodes.count(via.node) > 0; };
const auto via_on_path = [&](const auto via) { return nodes.contains(via.node); };
return std::remove_if(first, last, via_on_path);
}
@@ -308,7 +308,7 @@ RandIt filterPackedPathsByCellSharing(RandIt first,
{
const auto source_cell = get_cell(std::get<0>(edge));
const auto target_cell = get_cell(std::get<1>(edge));
return cells.count(source_cell) < 1 && cells.count(target_cell) < 1;
return !cells.contains(source_cell) && !cells.contains(target_cell);
};
const auto different = std::count_if(begin(packed.path), end(packed.path), not_seen);
@@ -491,7 +491,7 @@ RandIt filterUnpackedPathsBySharing(RandIt first,
{
auto node_duration = facade.GetNodeDuration(node);
total_duration += node_duration;
if (nodes.count(node) > 0)
if (nodes.contains(node))
{
return duration + node_duration;
}
@@ -325,7 +325,7 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
EdgeDuration initial_duration,
EdgeDistance initial_distance)
{
if (target_nodes_index.count(node))
if (target_nodes_index.contains(node))
{
// Source and target on the same edge node. If target is not reachable directly via
// the node (e.g destination is before source on oneway segment) we want to allow
+3 -3
View File
@@ -49,7 +49,7 @@ std::vector<TurnData> generateTurns(const datafacade &facade,
{
// operator[] will construct an empty vector at [edge.u] if there is no value.
directed_graph[edge.u].push_back({edge.v, edge.forward_segment_id.id});
if (edge_based_node_info.count(edge.forward_segment_id.id) == 0)
if (!edge_based_node_info.contains(edge.forward_segment_id.id))
{
edge_based_node_info[edge.forward_segment_id.id] = {true, get_geometry_id(edge)};
}
@@ -64,7 +64,7 @@ std::vector<TurnData> generateTurns(const datafacade &facade,
if (edge.reverse_segment_id.enabled)
{
directed_graph[edge.v].push_back({edge.u, edge.reverse_segment_id.id});
if (edge_based_node_info.count(edge.reverse_segment_id.id) == 0)
if (!edge_based_node_info.contains(edge.reverse_segment_id.id))
{
edge_based_node_info[edge.reverse_segment_id.id] = {false, get_geometry_id(edge)};
}
@@ -106,7 +106,7 @@ std::vector<TurnData> generateTurns(const datafacade &facade,
{
// If the target of this edge doesn't exist in our directed
// graph, it's probably outside the tile, so we can skip it
if (directed_graph.count(approachedge.target_node) == 0)
if (!directed_graph.contains(approachedge.target_node))
continue;
// For each of the outgoing edges from our target coordinate