Skip to content

Commit 71b3ecf

Browse files
committed
Fix clippy
1 parent 3d342da commit 71b3ecf

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

src/scheduler/scheduler.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::stat::SchedulerStat;
22
use super::work_bucket::*;
3-
use super::worker::{GCWorker, WorkerGroup};
3+
use super::worker::{GCWorker, StealerWithOrdinal, WorkerGroup};
44
use super::*;
55
use crate::mmtk::MMTK;
66
use crate::util::opaque_pointer::*;
@@ -119,13 +119,7 @@ impl<VM: VMBinding> GCWorkScheduler<VM> {
119119
{
120120
// Unconstrained is always open. Prepare will be opened at the beginning of a GC.
121121
// This vec will grow for each stage we call with open_next()
122-
let first_stw_stage = self
123-
.work_buckets
124-
.iter()
125-
.skip(1)
126-
.next()
127-
.map(|(id, _)| id)
128-
.unwrap();
122+
let first_stw_stage = self.work_buckets.iter().nth(1).map(|(id, _)| id).unwrap();
129123
let mut open_stages: Vec<WorkBucketStage> = vec![first_stw_stage];
130124
// The rest will open after the previous stage is done.
131125
let mut open_next = |s: WorkBucketStage| {
@@ -320,13 +314,7 @@ impl<VM: VMBinding> GCWorkScheduler<VM> {
320314
}
321315

322316
pub fn reset_state(&self) {
323-
let first_stw_stage = self
324-
.work_buckets
325-
.iter()
326-
.skip(1)
327-
.next()
328-
.map(|(id, _)| id)
329-
.unwrap();
317+
let first_stw_stage = self.work_buckets.iter().nth(1).map(|(id, _)| id).unwrap();
330318
self.work_buckets.iter().for_each(|(id, bkt)| {
331319
if id != WorkBucketStage::Unconstrained && id != first_stw_stage {
332320
bkt.deactivate();
@@ -366,7 +354,7 @@ impl<VM: VMBinding> GCWorkScheduler<VM> {
366354
_ => {}
367355
}
368356
}
369-
for (id, stealer) in &self.worker_group().stealers {
357+
for StealerWithOrdinal { id, stealer } in &self.worker_group().stealers {
370358
if *id == worker.ordinal {
371359
continue;
372360
}
@@ -463,7 +451,7 @@ impl<VM: VMBinding> GCWorkScheduler<VM> {
463451

464452
pub fn notify_mutators_paused(&self, mmtk: &'static MMTK<VM>) {
465453
mmtk.plan.base().control_collector_context.clear_request();
466-
let first_stw_bucket = self.work_buckets.values().skip(1).next().unwrap();
454+
let first_stw_bucket = self.work_buckets.values().nth(1).unwrap();
467455
debug_assert!(!first_stw_bucket.is_activated());
468456
first_stw_bucket.activate();
469457
let _guard = self.worker_monitor.0.lock().unwrap();

src/scheduler/worker.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,14 @@ impl<VM: VMBinding> GCWorker<VM> {
155155
}
156156
}
157157

158+
pub struct StealerWithOrdinal<VM: VMBinding> {
159+
pub id: usize,
160+
pub stealer: Stealer<Box<dyn GCWork<VM>>>,
161+
}
162+
158163
pub struct WorkerGroup<VM: VMBinding> {
159164
pub workers: Vec<GCWorker<VM>>,
160-
pub stealers: Vec<(usize, Stealer<Box<dyn GCWork<VM>>>)>,
165+
pub stealers: Vec<StealerWithOrdinal<VM>>,
161166
parked_workers: AtomicUsize,
162167
}
163168

@@ -172,7 +177,10 @@ impl<VM: VMBinding> WorkerGroup<VM> {
172177
.collect::<Vec<_>>();
173178
let stealers = workers
174179
.iter()
175-
.map(|w| (w.ordinal, w.local_work_buffer.stealer()))
180+
.map(|w| StealerWithOrdinal {
181+
id: w.ordinal,
182+
stealer: w.local_work_buffer.stealer(),
183+
})
176184
.collect();
177185
Arc::new(Self {
178186
workers,

0 commit comments

Comments
 (0)