From c6087de542540577cbeb535feb702a093a9eca3c Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 4 Mar 2021 17:24:55 +0100 Subject: [PATCH] Search::select_simple() doesn't need to take a length --- src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a14d04d..a32cc90 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -340,7 +340,7 @@ where } } - let nearest = search.select_simple(out.len()); + let nearest = &search.select_simple()[..out.len()]; for (i, candidate) in nearest.iter().enumerate() { out[i] = candidate.pid; } @@ -376,7 +376,7 @@ fn insert( heuristic: &Option, ) { let found = match heuristic { - None => search.select_simple(M * 2), + None => &search.select_simple()[..M * 2], Some(heuristic) => search.select_heuristic(&points[new], layer, points, *heuristic), }; @@ -653,8 +653,7 @@ impl Search { } /// Selection of neighbors for insertion (algorithm 3 from the paper) - fn select_simple(&mut self, num: usize) -> &[Candidate] { - self.nearest.truncate(num); + fn select_simple(&mut self) -> &[Candidate] { &self.nearest } }