Lower Layer impls to slice impls to fix clippy suggestion

This commit is contained in:
Dirkjan Ochtman 2021-01-20 18:25:29 +01:00
parent 2ab15e0c66
commit de38b64358
3 changed files with 9 additions and 9 deletions

View File

@ -10,7 +10,7 @@ benchmark_group!(benches, build_heuristic);
fn build_heuristic(bench: &mut Bencher) {
let seed = ThreadRng::default().gen::<u64>();
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::<Vec<_>>();

View File

@ -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<P: Point>(
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<P: Point>(
&mut self,
layer: &Vec<ZeroNode>,
layer: &[ZeroNode],
num: usize,
point: &P,
points: &[P],

View File

@ -69,7 +69,7 @@ impl UpperNode {
}
}
impl Layer for &Vec<UpperNode> {
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<ZeroNode> {
impl Layer for &[ZeroNode] {
fn nearest_iter(&self, pid: PointId) -> NearestIter<'_> {
NearestIter {
nearest: &self[pid.0 as usize].0,