Skip to content

Commit 4e3dc65

Browse files
committed
clippy
1 parent cad9115 commit 4e3dc65

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

crates/consistent-hashing/benchmarks/performance.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ use rand::{rng, Rng};
1414
fn throughput_benchmark(c: &mut Criterion) {
1515
let keys: Vec<u64> = rng().random_iter().take(1000).collect();
1616

17-
let mut group = c.benchmark_group(format!("choose"));
17+
let mut group = c.benchmark_group("choose");
1818
group.plot_config(PlotConfiguration::default().summary_scale(AxisScale::Logarithmic));
1919
for n in [1usize, 10, 100, 1000, 10000] {
2020
group.throughput(Throughput::Elements(keys.len() as u64));
21-
group.bench_with_input(BenchmarkId::new(format!("1"), n), &n, |b, n| {
21+
group.bench_with_input(BenchmarkId::new("1", n), &n, |b, n| {
2222
b.iter_batched(
2323
|| &keys,
2424
|keys| {
@@ -65,9 +65,9 @@ fn append_vs_new_with_k(c: &mut Criterion) {
6565
b.iter(|| {
6666
let h = DefaultHasher::default();
6767
let mut iter = ConsistentChooseKHasher::new(h, n + k);
68-
black_box(for _ in 0..k {
69-
iter.grow_k();
70-
})
68+
for _ in 0..k {
69+
black_box(iter.grow_k());
70+
}
7171
})
7272
});
7373
}

crates/consistent-hashing/src/node_map.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,8 @@ impl ConsistentNodeMap {
162162
if self.is_empty() {
163163
return None;
164164
}
165-
let iter = ConsistentChooseKHasher::new(builder, self.total);
166-
for pos in iter {
167-
if !self.deleted.contains(&pos) {
168-
return Some(pos);
169-
}
170-
}
171-
None
165+
let mut iter = ConsistentChooseKHasher::new(builder, self.total);
166+
iter.find(|pos| !self.deleted.contains(pos))
172167
}
173168
}
174169

0 commit comments

Comments
 (0)