Skip to content

Commit

Permalink
clippy: Fix some warnings in components/script/timers.rs (servo#31878)
Browse files Browse the repository at this point in the history
* Fixed some clippy warnings in components/script/timers.rs

* Formatted changes in components/script/timers.rs

* Updated changes in components/script/timers.rs

* Updated Default implementation of JsTimers in components/script/timers.rs

* UPDATED DEFAULT METHOD IMPLEMENTATION OF JsTimers in components/script/timers.rs
  • Loading branch information
jahielkomu authored and ektuu committed Mar 28, 2024
1 parent 5ddaedf commit 0b7d7a5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions components/script/timers.rs
Expand Up @@ -124,14 +124,14 @@ impl PartialOrd for OneshotTimer {
impl Eq for OneshotTimer {}
impl PartialEq for OneshotTimer {
fn eq(&self, other: &OneshotTimer) -> bool {
self as *const OneshotTimer == other as *const OneshotTimer
std::ptr::eq(self, other)
}
}

impl OneshotTimers {
pub fn new(scheduler_chan: IpcSender<TimerSchedulerMsg>) -> OneshotTimers {
OneshotTimers {
js_timers: JsTimers::new(),
js_timers: JsTimers::default(),
timer_event_chan: DomRefCell::new(None),
scheduler_chan,
next_timer_handle: Cell::new(OneshotTimerHandle(1)),
Expand Down Expand Up @@ -194,7 +194,7 @@ impl OneshotTimers {
fn is_next_timer(&self, handle: OneshotTimerHandle) -> bool {
match self.timers.borrow().last() {
None => false,
Some(ref max_timer) => max_timer.handle == handle,
Some(max_timer) => max_timer.handle == handle,
}
}

Expand Down Expand Up @@ -418,16 +418,18 @@ enum InternalTimerCallback {
),
}

impl JsTimers {
pub fn new() -> JsTimers {
impl Default for JsTimers {
fn default() -> Self {
JsTimers {
next_timer_handle: Cell::new(JsTimerHandle(1)),
active_timers: DomRefCell::new(HashMap::new()),
nesting_level: Cell::new(0),
min_duration: Cell::new(None),
}
}
}

impl JsTimers {
// see https://html.spec.whatwg.org/multipage/#timer-initialisation-steps
pub fn set_timeout_or_interval(
&self,
Expand Down

0 comments on commit 0b7d7a5

Please sign in to comment.