From 577dc7c26d1d6e8a55932e1c0d9f9c70f73e5ac8 Mon Sep 17 00:00:00 2001 From: Alain Emilia Anna Zscheile Date: Tue, 10 Dec 2024 23:49:00 +0100 Subject: [PATCH] refactor(triangulation): store boxed slice instead of vector for trianvertex_to_handle This vector never gets resized after construction. --- src/triangulation.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/triangulation.rs b/src/triangulation.rs index 39e6776..3160caf 100644 --- a/src/triangulation.rs +++ b/src/triangulation.rs @@ -17,7 +17,7 @@ pub struct Triangulation< EW: Copy + Default, > { triangulation: DelaunayTriangulation, - trianvertex_to_handle: Vec>, + trianvertex_to_handle: Box<[Option]>, index_marker: PhantomData, } @@ -28,13 +28,11 @@ impl< > Triangulation { pub fn new(node_bound: usize) -> Self { - let mut this = Self { + Self { triangulation: as spade::Triangulation>::new(), - trianvertex_to_handle: Vec::new(), + trianvertex_to_handle: vec![None; node_bound].into_boxed_slice(), index_marker: PhantomData, - }; - this.trianvertex_to_handle.resize(node_bound, None); - this + } } pub fn add_vertex(&mut self, weight: VW) -> Result<(), InsertionError> {