diff --git a/benches/all.rs b/benches/all.rs index 717a433..df88014 100644 --- a/benches/all.rs +++ b/benches/all.rs @@ -10,7 +10,7 @@ benchmark_group!(benches, build_heuristic); fn build_heuristic(bench: &mut Bencher) { let seed = ThreadRng::default().gen::(); let mut rng = StdRng::seed_from_u64(seed); - let points = (0..16384) + let points = (0..1024) .into_iter() .map(|_| Point(rng.gen(), rng.gen())) .collect::>(); diff --git a/src/lib.rs b/src/lib.rs index 1738d49..9508ccd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -260,11 +260,11 @@ where search.ef = if cur <= layer { ef_construction } else { 1 }; match cur > layer { true => { - search.search(point, &layers[cur.0 - 1], &points, num); + search.search(point, layers[cur.0 - 1].as_slice(), &points, num); search.cull(); } false => { - search.search(point, &zero, &points, num); + search.search(point, zero.as_slice(), &points, num); break; } } @@ -343,8 +343,8 @@ where search.ef = ef; match cur.0 { - 0 => search.search(point, &self.zero, &self.points, num), - l => search.search(point, &self.layers[l - 1], &self.points, num), + 0 => search.search(point, self.zero.as_slice(), &self.points, num), + l => search.search(point, self.layers[l - 1].as_slice(), &self.points, num), } if !cur.is_zero() { @@ -406,7 +406,7 @@ fn insert( insertion.reset(); let candidate_point = &points[pid]; insertion.push(new, candidate_point, points); - for hop in (&*layer).nearest_iter(pid) { + for hop in layer.as_slice().nearest_iter(pid) { insertion.push(hop, candidate_point, points); } @@ -537,7 +537,7 @@ impl Search { fn select_heuristic( &mut self, - layer: &Vec, + layer: &[ZeroNode], num: usize, point: &P, points: &[P], diff --git a/src/types.rs b/src/types.rs index 0682530..bd46af1 100644 --- a/src/types.rs +++ b/src/types.rs @@ -69,7 +69,7 @@ impl UpperNode { } } -impl Layer for &Vec { +impl Layer for &[UpperNode] { fn nearest_iter(&self, pid: PointId) -> NearestIter<'_> { NearestIter { nearest: &self[pid.0 as usize].0, @@ -128,7 +128,7 @@ impl Deref for ZeroNode { } } -impl Layer for &Vec { +impl Layer for &[ZeroNode] { fn nearest_iter(&self, pid: PointId) -> NearestIter<'_> { NearestIter { nearest: &self[pid.0 as usize].0,