From 2dd2c916eba5b834eaa06e2eb19a6d307302b03b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 8 Nov 2022 11:55:20 +0100 Subject: [PATCH] Remove redundant validation check We already check that all half-edges are connected by identical surface vertices. Checking the surface on top of that is redundant. --- crates/fj-kernel/src/objects/cycle.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/crates/fj-kernel/src/objects/cycle.rs b/crates/fj-kernel/src/objects/cycle.rs index 78fda9ad8..518064a22 100644 --- a/crates/fj-kernel/src/objects/cycle.rs +++ b/crates/fj-kernel/src/objects/cycle.rs @@ -24,20 +24,14 @@ impl Cycle { pub fn new(half_edges: impl IntoIterator>) -> Self { let half_edges = half_edges.into_iter().collect::>(); - let surface = match half_edges.first() { - Some(half_edge) => half_edge.surface().clone(), - None => panic!("Cycle must contain at least one half-edge"), - }; - - // Verify, that the curves of all edges are defined in the correct - // surface. - for edge in &half_edges { - assert_eq!( - surface.id(), - edge.curve().surface().id(), - "Edges in cycle not defined in same surface" - ); - } + // This is not a validation check, and thus not part of the validation + // infrastructure. The property being checked here is inherent to the + // validity of a `Cycle`, as methods of `Cycle` might assume that there + // is at least one edge. + assert!( + !half_edges.is_empty(), + "Cycle must contain at least one half-edge" + ); if half_edges.len() != 1 { // Verify that all edges connect.