diff --git a/pre/src/dijkstra.rs b/pre/src/dijkstra.rs index a6a7ee9..27e53ca 100644 --- a/pre/src/dijkstra.rs +++ b/pre/src/dijkstra.rs @@ -54,7 +54,7 @@ impl Dijkstra { self.heap.push(MinHeapItem::new(start, 0)); } if self.visited.is_visited(end) { - return self.resolve_path(end, &edges, with_path); + return Some(self.resolve_path(end, &edges, with_path)); } self.dist[start] = (0, None); self.reachable.set_visited(start); @@ -82,22 +82,17 @@ impl Dijkstra { self.visited.set_visited(node); // found end if node == end { - return self.resolve_path(end, &edges, with_path); + return Some(self.resolve_path(end, &edges, with_path)); } } None } /// recreate path, of already visited - fn resolve_path( - &self, - end: NodeId, - edges: &[Way], - with_path: bool, - ) -> Option<(Vec, usize)> { + fn resolve_path(&self, end: NodeId, edges: &[Way], with_path: bool) -> (Vec, usize) { let weight = self.dist[end].0; if !with_path { - return Some((Vec::new(), weight)); + return (Vec::new(), weight); } let mut path = Vec::with_capacity(self.dist.len() / 2); let mut current_dist = self.dist[end]; @@ -106,7 +101,7 @@ impl Dijkstra { current_dist = self.dist[edges[prev].source]; } path.reverse(); - Some((path, weight)) + (path, weight) } } diff --git a/pre/src/graph_helper.rs b/pre/src/graph_helper.rs index 7934d06..7a17eeb 100644 --- a/pre/src/graph_helper.rs +++ b/pre/src/graph_helper.rs @@ -3,7 +3,7 @@ use super::*; /// get all up edges from one node #[allow(dead_code)] pub fn get_edges_from_id(ids: Vec, edges: &[Way]) -> Vec { - return ids.par_iter().map(|x| edges[*x]).collect(); + return ids.iter().map(|x| edges[*x]).collect(); } /// get all up edge-ids from one node @@ -20,7 +20,7 @@ pub fn get_down_edge_ids( down_index: &[EdgeId], ) -> Vec { let prev: Vec = (down_offset[node]..down_offset[node + 1]).collect(); - return prev.par_iter().map(|x| down_index[*x]).collect(); + return prev.iter().map(|x| down_index[*x]).collect(); } /// get all down edge-ids from one node @@ -54,7 +54,7 @@ pub fn get_all_edge_ids( #[allow(dead_code)] pub fn get_up_neighbors(node: NodeId, edges: &[Way], up_offset: &[EdgeId]) -> Vec { let next = get_up_edge_ids(node, &up_offset); - let mut tmp: Vec = next.par_iter().map(|x| edges[*x].target).collect(); + let mut tmp: Vec = next.iter().map(|x| edges[*x].target).collect(); tmp.dedup(); tmp } @@ -68,7 +68,7 @@ pub fn get_down_neighbors( down_index: &[EdgeId], ) -> Vec { let prev = get_down_edge_ids(node, &down_offset, &down_index); - let mut tmp: Vec = prev.par_iter().map(|x| edges[*x].source).collect(); + let mut tmp: Vec = prev.iter().map(|x| edges[*x].source).collect(); tmp.par_sort_unstable(); tmp.dedup(); tmp diff --git a/pre/src/grid.rs b/pre/src/grid.rs index b9afd8f..f7764a7 100644 --- a/pre/src/grid.rs +++ b/pre/src/grid.rs @@ -30,12 +30,14 @@ fn get_min_max(nodes: &[Node]) -> GridBounds { } } +#[allow(clippy::suspicious_operation_groupings)] fn get_grid_lat(node: &Node, grid_bounds: &GridBounds) -> usize { let lat_percent = (node.latitude - grid_bounds.lat_min) / (grid_bounds.lat_max - grid_bounds.lat_min); (lat_percent * (LAT_GRID_AMOUNT - 1) as f32) as usize } +#[allow(clippy::suspicious_operation_groupings)] fn get_grid_lng(node: &Node, grid_bounds: &GridBounds) -> usize { let lng_percent = (node.longitude - grid_bounds.lng_min) / (grid_bounds.lng_max - grid_bounds.lng_min); diff --git a/pre/src/offset.rs b/pre/src/offset.rs index cde701b..d041020 100644 --- a/pre/src/offset.rs +++ b/pre/src/offset.rs @@ -23,12 +23,12 @@ pub fn generate_offsets_unstable( down_offset.resize(amount_nodes + 1, 0); // generate up edges - let sources: Vec = edges.par_iter().map(|x| x.source).rev().collect(); + let sources: Vec = edges.iter().map(|x| x.source).rev().collect(); fill_offset(sources, &mut up_offset); // generate down edges, but without sorting edges // first collect offsets - let targets: Vec = edges.par_iter().map(|x| x.target).rev().collect(); + let targets: Vec = edges.iter().map(|x| x.target).rev().collect(); fill_offset(targets, &mut down_offset); let mut down_index = vec![INVALID_EDGE; edges.len()]; // fill offsets, where not already filled diff --git a/web/src/bidijkstra.rs b/web/src/bidijkstra.rs index a4ce6e0..be84973 100644 --- a/web/src/bidijkstra.rs +++ b/web/src/bidijkstra.rs @@ -5,8 +5,8 @@ use visited_list::*; #[derive(Clone)] pub struct Dijkstra { - dist_up: Vec<(NodeId, Option)>, - dist_down: Vec<(NodeId, Option)>, + dist_up: Vec<(Weight, Option)>, + dist_down: Vec<(Weight, Option)>, visited_up: VisitedList, visited_down: VisitedList, heap_up: BinaryHeap, @@ -145,7 +145,7 @@ impl Dijkstra { if meeting_node == INVALID_NODE { None } else { - self.resolve_path(meeting_node, best_weight, nodes[meeting_node].rank, &edges) + Some(self.resolve_path(meeting_node, best_weight, nodes[meeting_node].rank, &edges)) } } @@ -156,7 +156,7 @@ impl Dijkstra { weight: Weight, meeting_rank: Rank, edges: &[Way], - ) -> Option<(Vec, f32)> { + ) -> (Vec, f32) { assert!(self.visited_up.is_visited(meeting_node)); assert!(self.visited_down.is_visited(meeting_node)); @@ -174,7 +174,7 @@ impl Dijkstra { self.walk_down(down_edge.1.unwrap(), false, &mut path, &edges); } - Some((path, weight as f32 / DIST_MULTIPLICATOR as f32)) + (path, weight as f32 / DIST_MULTIPLICATOR as f32) } // walk shortcuts from meeting point to end diff --git a/web/src/graph_helper.rs b/web/src/graph_helper.rs index cb77f6f..31fc3d0 100644 --- a/web/src/graph_helper.rs +++ b/web/src/graph_helper.rs @@ -3,7 +3,7 @@ use super::*; /// get all up edges from one node #[allow(dead_code)] pub fn get_edges_from_id(ids: Vec, edges: &[Way]) -> Vec { - return ids.par_iter().map(|x| edges[*x]).collect(); + return ids.iter().map(|x| edges[*x]).collect(); } /// get all up edge-ids from one node @@ -20,7 +20,7 @@ pub fn get_down_edge_ids( down_index: &[EdgeId], ) -> Vec { let prev: Vec = (down_offset[node]..down_offset[node + 1]).collect(); - return prev.par_iter().map(|x| down_index[*x]).collect(); + return prev.iter().map(|x| down_index[*x]).collect(); } /// get all down edge-ids from one node @@ -54,7 +54,7 @@ pub fn get_all_edge_ids( #[allow(dead_code)] pub fn get_up_neighbors(node: NodeId, edges: &[Way], up_offset: &[EdgeId]) -> Vec { let next = get_up_edge_ids(node, &up_offset); - let mut tmp: Vec = next.par_iter().map(|x| edges[*x].target).collect(); + let mut tmp: Vec = next.iter().map(|x| edges[*x].target).collect(); tmp.dedup(); tmp } @@ -68,7 +68,7 @@ pub fn get_down_neighbors( down_index: &[EdgeId], ) -> Vec { let prev = get_down_edge_ids(node, &down_offset, &down_index); - let mut tmp: Vec = prev.par_iter().map(|x| edges[*x].source).collect(); + let mut tmp: Vec = prev.iter().map(|x| edges[*x].source).collect(); tmp.par_sort_unstable(); tmp.dedup(); tmp diff --git a/web/src/grid.rs b/web/src/grid.rs index c7e2826..ff2f17c 100644 --- a/web/src/grid.rs +++ b/web/src/grid.rs @@ -146,12 +146,14 @@ fn get_points_from_cells( result } +#[allow(clippy::suspicious_operation_groupings)] fn get_grid_lat(node: &Node, grid_bounds: &GridBounds) -> usize { let lat_percent = (node.latitude - grid_bounds.lat_min) / (grid_bounds.lat_max - grid_bounds.lat_min); (lat_percent * (LAT_GRID_AMOUNT - 1) as f32) as usize } +#[allow(clippy::suspicious_operation_groupings)] fn get_grid_lng(node: &Node, grid_bounds: &GridBounds) -> usize { let lng_percent = (node.longitude - grid_bounds.lng_min) / (grid_bounds.lng_max - grid_bounds.lng_min);