From be09ca52b7c951457117190d0e7536d30c95d4c8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Dec 2022 16:00:33 +0100 Subject: [PATCH] Simplify `CycleBuilder` method --- crates/fj-kernel/src/builder/cycle.rs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index 31d279e73..4944c8b61 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -53,25 +53,18 @@ impl CycleBuilder for PartialCycle { points: impl IntoIterator>>, ) -> Vec> { let surface = surface.into(); - let points = points.into_iter().map(Into::into); + let mut points = points.into_iter().map(Into::into); let mut half_edges = Vec::new(); - for point in points { - let mut half_edge = self.add_half_edge(); - - { - let mut half_edge = half_edge.write(); - - half_edge.curve().write().surface = surface.clone(); - - let mut back = half_edge.back_mut().write(); - let mut back_surface = back.surface_form.write(); - - back_surface.position = Some(point); - back_surface.surface = surface.clone(); - } + if let Some(point) = points.next() { + let mut half_edge = self.add_half_edge_from_point_to_start(point); + half_edge.write().replace_surface(surface); + half_edges.push(half_edge); + } + for point in points { + let half_edge = self.add_half_edge_from_point_to_start(point); half_edges.push(half_edge); }