Skip to content

Commit b180d33

Browse files
committed
chore: Optimize code.
1 parent bddefb0 commit b180d33

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

src/timer/runtime_trace/sweeper.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,16 @@ impl RecyclingBins {
101101
let now: u64 = timestamp();
102102
let mut duration: Option<Duration> = None;
103103
for _ in 0..200 {
104-
if let Some(recycle_flag) = (&recycle_unit_heap).peek().map(|r| r.0.deadline <= now)
105-
{
104+
if let Some(recycle_flag) = recycle_unit_heap.peek().map(|r| r.0.deadline <= now) {
106105
if !recycle_flag {
107-
duration = (&recycle_unit_heap)
106+
duration = recycle_unit_heap
108107
.peek()
109108
.map(|r| r.0.deadline - now)
110109
.map(Duration::from_secs);
111110
break;
112111
}
113112

114-
if let Some(recycle_unit) = (&mut recycle_unit_heap).pop().map(|v| v.0) {
113+
if let Some(recycle_unit) = recycle_unit_heap.pop().map(|v| v.0) {
115114
//handle send-error.
116115
self.send_timer_event(TimerEvent::TimeoutTask(
117116
recycle_unit.task_id,
@@ -151,7 +150,7 @@ impl RecyclingBins {
151150
Ok(recycle_unit) => {
152151
let mut recycle_unit_heap = self.recycle_unit_heap.lock().await;
153152

154-
(&mut recycle_unit_heap).push(Reverse(recycle_unit));
153+
recycle_unit_heap.push(Reverse(recycle_unit));
155154
}
156155

157156
Err(_) => {

src/timer/runtime_trace/task_handle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ use tokio::task::JoinHandle;
287287
//TODO:remove debug.
288288
impl<T: Send + Sync + Debug + 'static> DelayTaskHandler for JoinHandle<T> {
289289
fn quit(self: Box<Self>) -> Result<()> {
290-
(&*self).abort();
290+
(*self).abort();
291291
Ok(())
292292
}
293293
}

src/timer/task.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ impl<F: Fn() -> U + 'static + Send, U: Future + 'static + Send> Routine for Asyn
570570

571571
#[inline(always)]
572572
fn spawn_by_tokio(&self, task_context: TaskContext) -> Self::TokioHandle {
573-
let user_future = (&self.0)();
573+
let user_future = self.0();
574574

575575
async_spawn_by_tokio({
576576
let task_id = task_context.task_id;
@@ -589,7 +589,7 @@ impl<F: Fn() -> U + 'static + Send, U: Future + 'static + Send> Routine for Asyn
589589

590590
#[inline(always)]
591591
fn spawn_by_smol(&self, task_context: TaskContext) -> Self::SmolHandle {
592-
let user_future = (&self.0)();
592+
let user_future = self.0();
593593

594594
async_spawn_by_smol({
595595
let task_id = task_context.task_id;
@@ -623,7 +623,7 @@ impl<F: Fn() + 'static + Send + Clone> Routine for SyncFn<F> {
623623

624624
#[inline(always)]
625625
fn spawn_by_tokio(&self, task_context: TaskContext) -> Self::TokioHandle {
626-
let fn_handle = unblock_spawn_by_tokio((&self.0).clone());
626+
let fn_handle = unblock_spawn_by_tokio(self.0.clone());
627627

628628
let task_id = task_context.task_id;
629629
let record_id = task_context.record_id;
@@ -645,7 +645,7 @@ impl<F: Fn() + 'static + Send + Clone> Routine for SyncFn<F> {
645645

646646
#[inline(always)]
647647
fn spawn_by_smol(&self, task_context: TaskContext) -> Self::SmolHandle {
648-
let fn_handle = unblock_spawn_by_smol((&self.0).clone());
648+
let fn_handle = unblock_spawn_by_smol(self.0.clone());
649649

650650
let task_id = task_context.task_id;
651651
let record_id = task_context.record_id;

src/utils/parse.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ pub mod shell_command {
6363
/// Abstraction of command methods in multiple libraries.
6464
pub trait CommandUnify<Child: ChildUnify>: Sized {
6565
/// Constructs a new Command for launching the program at path program.
66-
// FIXME:
67-
fn new<S: AsRef<OsStr>>(program: S) -> Self {
68-
Self::new(program.as_ref())
69-
}
66+
fn new<S: AsRef<OsStr>>(program: S) -> Self;
7067

7168
/// Adds multiple arguments to pass to the program.
7269
fn args<I, S>(&mut self, args: I) -> &mut Self

0 commit comments

Comments
 (0)