From 1136862d73f8f2fd28e3ccd79c4d5cc310585ce4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 7 Oct 2022 13:26:53 +0200 Subject: [PATCH 1/3] Fix comment --- crates/fj-kernel/src/stores/handle.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/stores/handle.rs b/crates/fj-kernel/src/stores/handle.rs index a86263ff8..ca77918d9 100644 --- a/crates/fj-kernel/src/stores/handle.rs +++ b/crates/fj-kernel/src/stores/handle.rs @@ -56,7 +56,7 @@ impl Deref for Handle { // has at least been reserved. // 2. That the memory objects live in is never deallocated. // - // That means that as long as a `Handle` exists, the object is + // That means that as long as a `Handle` exists, the object it // references has at least been reserved, and has not been deallocated. // // Given all this, we know that the following must be true: @@ -71,7 +71,7 @@ impl Deref for Handle { // the reference we return here are enforced. // // Furthermore, all of the code mentioned here is covered by unit tests, - // which I've run successfully run under Miri. + // which I've run successfully under Miri. let cell = unsafe { &*self.ptr }; // Can only happen, if the object has been reserved, but the reservation From e9d96441407ef2e019a2aad65e2fd381227809fa Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 7 Oct 2022 14:19:45 +0200 Subject: [PATCH 2/3] Simplify construction of `Curve` --- .../src/algorithms/intersect/surface_surface.rs | 3 +-- crates/fj-kernel/src/algorithms/sweep/edge.rs | 11 ++++------- crates/fj-kernel/src/algorithms/sweep/vertex.rs | 7 ++++--- crates/fj-kernel/src/algorithms/validate/mod.rs | 4 ++-- crates/fj-kernel/src/objects/curve.rs | 8 ++++---- crates/fj-kernel/src/partial/objects/curve.rs | 4 +--- 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs index cb0e9ea1a..a7350c56c 100644 --- a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs +++ b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs @@ -58,9 +58,8 @@ impl SurfaceSurfaceIntersection { let curves = surfaces_and_planes.map(|(surface, plane)| { let path = SurfacePath::Line(plane.project_line(&line)); let global_form = GlobalCurve::new(stores); - let curve = Curve::new(surface, path, global_form); - stores.curves.insert(curve) + Curve::new(surface, path, global_form, stores) }); Some(Self { diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 36f745545..42da2f812 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -40,13 +40,12 @@ impl Sweep for (HalfEdge, Color) { points_curve_and_surface, )); - let curve = Curve::new( + Curve::new( surface.clone(), path, edge.curve().global_form().clone(), - ); - - stores.curves.insert(curve) + stores, + ) }; let vertices = { @@ -111,9 +110,7 @@ impl Sweep for (HalfEdge, Color) { points_curve_and_surface, )); - let curve = Curve::new(surface.clone(), path, global); - - stores.curves.insert(curve) + Curve::new(surface.clone(), path, global, stores) }; let global = diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index 04835a3ac..7f541c1dd 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -79,12 +79,13 @@ impl Sweep for (Vertex, Handle) { // `Edge` is straight-forward. let curve = { let line = Line::from_points(points_surface); - let curve = Curve::new( + + Curve::new( surface.clone(), SurfacePath::Line(line), edge_global.curve().clone(), - ); - stores.curves.insert(curve) + stores, + ) }; // And now the vertices. Again, nothing wild here. diff --git a/crates/fj-kernel/src/algorithms/validate/mod.rs b/crates/fj-kernel/src/algorithms/validate/mod.rs index bc294e214..80fc99529 100644 --- a/crates/fj-kernel/src/algorithms/validate/mod.rs +++ b/crates/fj-kernel/src/algorithms/validate/mod.rs @@ -177,8 +177,8 @@ mod tests { let curve = { let path = SurfacePath::line_from_points(points_surface); let global_form = GlobalCurve::new(&stores); - let curve = Curve::new(surface.clone(), path, global_form); - stores.curves.insert(curve) + + Curve::new(surface.clone(), path, global_form, &stores) }; let [a_global, b_global] = diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index 693739c05..d43d7e078 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -19,14 +19,14 @@ impl Curve { surface: Handle, path: SurfacePath, global_form: impl Into>, - ) -> Self { + stores: &Stores, + ) -> Handle { let global_form = global_form.into(); - - Self { + stores.curves.insert(Self { surface, path, global_form, - } + }) } /// Access the path that defines this curve diff --git a/crates/fj-kernel/src/partial/objects/curve.rs b/crates/fj-kernel/src/partial/objects/curve.rs index 6a8b4ff4e..75acbe30a 100644 --- a/crates/fj-kernel/src/partial/objects/curve.rs +++ b/crates/fj-kernel/src/partial/objects/curve.rs @@ -92,9 +92,7 @@ impl PartialCurve { .global_form .unwrap_or_else(|| GlobalCurve::new(stores).into()); - let curve = Curve::new(surface, path, global_form); - - stores.curves.insert(curve) + Curve::new(surface, path, global_form, stores) } } From 707d0ae57c846a2a149012f18782c8d79d69a128 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 7 Oct 2022 14:22:49 +0200 Subject: [PATCH 3/3] Refactor --- crates/fj-kernel/src/objects/curve.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index d43d7e078..8280b8abf 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -21,11 +21,10 @@ impl Curve { global_form: impl Into>, stores: &Stores, ) -> Handle { - let global_form = global_form.into(); stores.curves.insert(Self { surface, path, - global_form, + global_form: global_form.into(), }) }