From ad086d6ed72888ca82f34ebe829e04380aa2d5fd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 14 Jul 2022 14:44:57 +0200 Subject: [PATCH 1/2] Derive `Copy` for `VerticesOfEdge` --- crates/fj-kernel/src/algorithms/approx/cycles.rs | 2 +- crates/fj-kernel/src/algorithms/reverse.rs | 2 +- crates/fj-kernel/src/algorithms/sweep.rs | 5 +---- crates/fj-kernel/src/objects/edge.rs | 2 +- crates/fj-operations/src/difference_2d.rs | 6 +++--- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/cycles.rs b/crates/fj-kernel/src/algorithms/approx/cycles.rs index 92beb23e0..5a43a4e01 100644 --- a/crates/fj-kernel/src/algorithms/approx/cycles.rs +++ b/crates/fj-kernel/src/algorithms/approx/cycles.rs @@ -22,7 +22,7 @@ impl CycleApprox { for edge in &cycle.edges { let mut edge_points = Vec::new(); approx_curve(&edge.curve(), tolerance, &mut edge_points); - approx_edge(edge.vertices.clone(), &mut edge_points); + approx_edge(edge.vertices, &mut edge_points); points.extend(edge_points.into_iter().map(|point| { let local = diff --git a/crates/fj-kernel/src/algorithms/reverse.rs b/crates/fj-kernel/src/algorithms/reverse.rs index e06d9eeff..48faa0606 100644 --- a/crates/fj-kernel/src/algorithms/reverse.rs +++ b/crates/fj-kernel/src/algorithms/reverse.rs @@ -51,7 +51,7 @@ fn reverse_local_coordinates_in_cycle( Local::new(local, edge.curve.global()) }; - let vertices = edge.vertices.clone(); + let vertices = edge.vertices; Edge { curve, vertices } }) diff --git a/crates/fj-kernel/src/algorithms/sweep.rs b/crates/fj-kernel/src/algorithms/sweep.rs index 63373fa2a..ec7b73532 100644 --- a/crates/fj-kernel/src/algorithms/sweep.rs +++ b/crates/fj-kernel/src/algorithms/sweep.rs @@ -152,10 +152,7 @@ fn create_non_continuous_side_face( Vertex::new(Point::from([1.]), b.1), ]); - let edge = Edge { - curve, - vertices: vertices.clone(), - }; + let edge = Edge { curve, vertices }; edges.push(edge); } diff --git a/crates/fj-kernel/src/objects/edge.rs b/crates/fj-kernel/src/objects/edge.rs index 0524c3815..f05832c90 100644 --- a/crates/fj-kernel/src/objects/edge.rs +++ b/crates/fj-kernel/src/objects/edge.rs @@ -104,7 +104,7 @@ impl fmt::Display for Edge { } /// The vertices that bound an edge -#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct VerticesOfEdge(Option<[Vertex; 2]>); impl VerticesOfEdge { diff --git a/crates/fj-operations/src/difference_2d.rs b/crates/fj-operations/src/difference_2d.rs index a65a9e989..a5db4e5b7 100644 --- a/crates/fj-operations/src/difference_2d.rs +++ b/crates/fj-operations/src/difference_2d.rs @@ -109,14 +109,14 @@ fn add_cycle(cycle: Cycle, reverse: bool) -> Cycle { }; let vertices = if reverse { - edge.vertices.clone().reverse() + edge.vertices.reverse() } else { - edge.vertices.clone() + edge.vertices }; let edge = Edge { curve: Local::new(curve_local, curve_canonical), - vertices: vertices.clone(), + vertices, }; edges.push(edge); From ddcf82c9d22116051f44c2fcd559fadee2faa122 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 14 Jul 2022 14:45:37 +0200 Subject: [PATCH 2/2] Inline variable --- crates/fj-kernel/src/algorithms/reverse.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/reverse.rs b/crates/fj-kernel/src/algorithms/reverse.rs index 48faa0606..6f737224b 100644 --- a/crates/fj-kernel/src/algorithms/reverse.rs +++ b/crates/fj-kernel/src/algorithms/reverse.rs @@ -51,9 +51,11 @@ fn reverse_local_coordinates_in_cycle( Local::new(local, edge.curve.global()) }; - let vertices = edge.vertices; - Edge { curve, vertices } + Edge { + curve, + vertices: edge.vertices, + } }) .collect();