refactor(triangulation): store boxed slice instead of vector for trianvertex_to_handle

This vector never gets resized after construction.
This commit is contained in:
Alain Emilia Anna Zscheile 2024-12-10 23:49:00 +01:00
parent ba0d441513
commit 577dc7c26d
1 changed files with 4 additions and 6 deletions

View File

@ -17,7 +17,7 @@ pub struct Triangulation<
EW: Copy + Default,
> {
triangulation: DelaunayTriangulation<VW, EW>,
trianvertex_to_handle: Vec<Option<FixedVertexHandle>>,
trianvertex_to_handle: Box<[Option<FixedVertexHandle>]>,
index_marker: PhantomData<I>,
}
@ -28,13 +28,11 @@ impl<
> Triangulation<I, VW, EW>
{
pub fn new(node_bound: usize) -> Self {
let mut this = Self {
Self {
triangulation: <DelaunayTriangulation<VW, EW> 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> {