Skip to content

Commit 12eaeb0

Browse files
committed
cargo clippy fix
1 parent 0a28dec commit 12eaeb0

File tree

9 files changed

+21
-39
lines changed

9 files changed

+21
-39
lines changed

benches/kanal_async.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ fn benchmark_kanal_async(c: &mut Criterion) {
206206

207207
for task_count in TASKS {
208208
let func_name = format!(
209-
"Kanal Async: {} threads, {} enq tasks enqueuing 1 million items, 1 looping deq task",
210-
thread_num, task_count
209+
"Kanal Async: {thread_num} threads, {task_count} enq tasks enqueuing 1 million items, 1 looping deq task"
211210
);
212211

213212
c.bench_with_input(

benches/srb_cft.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ fn benchmark_cft(c: &mut Criterion) {
107107
for shard_num in SHARDS {
108108
for task_count in TASKS {
109109
let func_name = format!(
110-
"CFT: {} threads, {} shards, {} enq tasks enqueuing 1 million items, {} looping deq task",
111-
thread_num, shard_num, task_count, shard_num
110+
"CFT: {thread_num} threads, {shard_num} shards, {task_count} enq tasks enqueuing 1 million items, {shard_num} looping deq task"
112111
);
113112

114113
c.bench_with_input(
@@ -136,8 +135,7 @@ fn benchmark_cft(c: &mut Criterion) {
136135
for shard_num in SHARDS {
137136
for task_count in TASKS {
138137
let func_name = format!(
139-
"Pin: {} threads, {} shards, {} enq tasks enqueuing 1 million items, {} looping deq full task",
140-
thread_num, shard_num, task_count, shard_num
138+
"Pin: {thread_num} threads, {shard_num} shards, {task_count} enq tasks enqueuing 1 million items, {shard_num} looping deq full task"
141139
);
142140

143141
c.bench_with_input(

benches/srb_pin.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use criterion::async_executor::AsyncExecutor;
22
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
33
use sharded_ringbuf::{
4-
MLFShardedRingBuf, ShardPolicy, mlf_spawn_dequeuer_unbounded, mlf_spawn_enqueuer_with_iterator, spawn_dequeuer_full_unbounded,
5-
spawn_enqueuer_full_with_iterator,
4+
MLFShardedRingBuf, ShardPolicy, mlf_spawn_dequeuer_unbounded, mlf_spawn_enqueuer_with_iterator,
5+
spawn_dequeuer_full_unbounded, spawn_enqueuer_full_with_iterator,
66
};
77
use sharded_ringbuf::{ShardedRingBuf, spawn_dequeuer_unbounded, spawn_enqueuer_with_iterator};
88
use smol::future;
@@ -712,8 +712,7 @@ fn benchmark_pin(c: &mut Criterion) {
712712
for shard_num in SHARDS {
713713
for task_count in TASKS {
714714
let func_name = format!(
715-
"Pin: {} threads, {} shards, {} enq tasks enqueuing 1 million items, {} looping deq task",
716-
thread_num, shard_num, task_count, shard_num
715+
"Pin: {thread_num} threads, {shard_num} shards, {task_count} enq tasks enqueuing 1 million items, {shard_num} looping deq task"
717716
);
718717

719718
c.bench_with_input(

benches/srb_randomsweep.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ fn benchmark_random_and_sweep(c: &mut Criterion) {
9696
for shard_num in SHARDS {
9797
for task_count in TASKS {
9898
let func_name = format!(
99-
"RandomAndSweep: {} threads, {} shards, {} enq tasks enqueuing 1 million items, {} looping deq task",
100-
thread_num, shard_num, task_count, shard_num
99+
"RandomAndSweep: {thread_num} threads, {shard_num} shards, {task_count} enq tasks enqueuing 1 million items, {shard_num} looping deq task"
101100
);
102101

103102
c.bench_with_input(
@@ -125,8 +124,7 @@ fn benchmark_random_and_sweep(c: &mut Criterion) {
125124
for shard_num in SHARDS {
126125
for task_count in TASKS {
127126
let func_name = format!(
128-
"RandomAndSweep: {} threads, {} shards, {} enq tasks enqueuing 1 million items, {} looping deq full task",
129-
thread_num, shard_num, task_count, shard_num
127+
"RandomAndSweep: {thread_num} threads, {shard_num} shards, {task_count} enq tasks enqueuing 1 million items, {shard_num} looping deq full task"
130128
);
131129

132130
c.bench_with_input(

benches/srb_shiftby.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ fn benchmark_shiftby(c: &mut Criterion) {
122122
for shard_num in SHARDS {
123123
for task_count in TASKS {
124124
let func_name = format!(
125-
"ShiftBy: {} threads, {} shards, {} enq tasks enqueuing 1 million items, {} looping deq task",
126-
thread_num, shard_num, task_count, shard_num
125+
"ShiftBy: {thread_num} threads, {shard_num} shards, {task_count} enq tasks enqueuing 1 million items, {shard_num} looping deq task"
127126
);
128127

129128
c.bench_with_input(
@@ -151,8 +150,7 @@ fn benchmark_shiftby(c: &mut Criterion) {
151150
for shard_num in SHARDS {
152151
for task_count in TASKS {
153152
let func_name = format!(
154-
"ShiftBy: {} threads, {} shards, {} enq tasks enqueuing 1 million items, {} looping deq full task",
155-
thread_num, shard_num, task_count, shard_num
153+
"ShiftBy: {thread_num} threads, {shard_num} shards, {task_count} enq tasks enqueuing 1 million items, {shard_num} looping deq full task"
156154
);
157155

158156
c.bench_with_input(

benches/srb_sweep.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ fn benchmark_sweep(c: &mut Criterion) {
118118
for shard_num in SHARDS {
119119
for task_count in TASKS {
120120
let func_name = format!(
121-
"Sweep: {} threads, {} shards, {} enq tasks enqueuing 1 million items, {} looping deq task",
122-
thread_num, shard_num, task_count, shard_num
121+
"Sweep: {thread_num} threads, {shard_num} shards, {task_count} enq tasks enqueuing 1 million items, {shard_num} looping deq task"
123122
);
124123

125124
c.bench_with_input(
@@ -147,8 +146,7 @@ fn benchmark_sweep(c: &mut Criterion) {
147146
for shard_num in SHARDS {
148147
for task_count in TASKS {
149148
let func_name = format!(
150-
"Sweep: {} threads, {} shards, {} enq tasks enqueuing 1 million items, {} looping deq full task",
151-
thread_num, shard_num, task_count, shard_num
149+
"Sweep: {thread_num} threads, {shard_num} shards, {task_count} enq tasks enqueuing 1 million items, {shard_num} looping deq full task"
152150
);
153151

154152
c.bench_with_input(

src/mlf_shardedringbuf.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,8 @@ impl<T> MLFShardedRingBuf<T> {
302302

303303
// SAFETY: Only one thread will perform this operation
304304
// And it's guaranteed that an item will exist here
305-
let item = unsafe { (*item_cell).assume_init_read() };
306305

307-
item
306+
unsafe { (*item_cell).assume_init_read() }
308307
}
309308

310309
/// Retrieves an item of type T from the RingBuffer if an item exists in the buffer.
@@ -601,11 +600,7 @@ impl<T> MLFShardedRingBuf<T> {
601600
unsafe {
602601
if self.is_item_in_shard(item_ind, shard_ind) {
603602
let val_ref = (*inner.items[item_ind].item.get()).assume_init_ref();
604-
if let Some(val_ref) = val_ref {
605-
Some(val_ref.clone())
606-
} else {
607-
None
608-
}
603+
val_ref.clone()
609604
} else {
610605
None
611606
}

src/shardedringbuf.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,10 @@ impl<T> ShardedRingBuf<T> {
375375
self.job_post_shard_notifs[current].notified().await;
376376
continue;
377377
}
378-
} else {
379-
if matches!(get_shard_policy(), ShardPolicyKind::Pin) {
380-
self.job_post_shard_notifs[current].notify_one();
381-
self.job_space_shard_notifs[current].notified().await;
382-
continue;
383-
}
378+
} else if matches!(get_shard_policy(), ShardPolicyKind::Pin) {
379+
self.job_post_shard_notifs[current].notify_one();
380+
self.job_space_shard_notifs[current].notified().await;
381+
continue;
384382
}
385383
// any other policies go through a yield_now() approach.
386384
}
@@ -589,7 +587,6 @@ impl<T> ShardedRingBuf<T> {
589587

590588
// SAFETY: Only one thread will perform this operation
591589
// And it's guaranteed that an item will exist here
592-
let item = unsafe { (*item_cell).assume_init_read() };
593590

594591
// SAFETY: We just copied the item by value, so we no longer need to hold
595592
// this item in memory
@@ -599,7 +596,7 @@ impl<T> ShardedRingBuf<T> {
599596
// ^ Note don't do this: I misunderstood assume_init_read() when it said
600597
// "resulting T is subject to the usual drop handling"; it just means that
601598
// you have T, and T will act accordingly with T's Drop when T goes out of scope
602-
item
599+
unsafe { (*item_cell).assume_init_read() }
603600
}
604601

605602
/// Retrieves an item of type T from the RingBuffer if an item exists in the buffer.

src/task_local_spawn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ where
382382
}
383383
}
384384
// println!("done");
385-
let _ = match policy {
385+
match policy {
386386
ShardPolicy::Sweep { initial_index } => {}
387387
ShardPolicy::RandomAndSweep => {}
388388
ShardPolicy::ShiftBy {
@@ -692,7 +692,7 @@ where
692692
}
693693
}
694694

695-
if enq_vec.len() != 0 {
695+
if !enq_vec.is_empty() {
696696
buffer.enqueue_full(enq_vec).await;
697697
}
698698

0 commit comments

Comments
 (0)