clippy: Fix clippy problems in components/script/dom (#31891)

* deref on an immutable reference

* use of  with literal radix of 10

* fix
This commit is contained in:
Rosemary Ajayi 2024-03-27 18:36:16 +00:00 committed by GitHub
parent b476bbafde
commit a5bcae212a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 13 deletions

View file

@ -5,7 +5,6 @@
use std::cell::Cell;
use std::collections::hash_map::Entry;
use std::collections::{HashMap, VecDeque};
use std::mem;
use std::rc::Rc;
use std::sync::{Arc, Mutex};

View file

@ -247,7 +247,7 @@ impl LiveDOMReferences {
#[allow(crown::unrooted_must_root)]
fn addref_promise(&self, promise: Rc<Promise>) {
let mut table = self.promise_table.borrow_mut();
table.entry(&*promise).or_insert(vec![]).push(promise)
table.entry(&*promise).or_default().push(promise)
}
/// ptr must be a pointer to a type that implements DOMObject.
@ -297,7 +297,7 @@ fn remove_nulls<K: Eq + Hash + Clone, V>(table: &mut HashMap<K, Weak<V>>) {
#[allow(crown::unrooted_must_root)]
pub unsafe fn trace_refcounted_objects(tracer: *mut JSTracer) {
info!("tracing live refcounted references");
LIVE_REFERENCES.with(|ref r| {
LIVE_REFERENCES.with(|r| {
let r = r.borrow();
let live_references = r.as_ref().unwrap();
{

View file

@ -64,7 +64,7 @@ where
pub unsafe fn new(value: T) -> Self {
unsafe fn add_to_root_list(object: *const dyn JSTraceable) -> *const RootCollection {
assert_in_script();
STACK_ROOTS.with(|ref root_list| {
STACK_ROOTS.with(|root_list| {
let root_list = &*root_list.get().unwrap();
root_list.root(object);
root_list
@ -208,7 +208,7 @@ where
T: DomObject,
{
fn clone(&self) -> DomRoot<T> {
DomRoot::from_ref(&*self)
DomRoot::from_ref(self)
}
}
@ -244,7 +244,7 @@ impl<'a> ThreadLocalStackRoots<'a> {
impl<'a> Drop for ThreadLocalStackRoots<'a> {
fn drop(&mut self) {
STACK_ROOTS.with(|ref r| r.set(None));
STACK_ROOTS.with(|r| r.set(None));
}
}
@ -282,7 +282,7 @@ impl RootCollection {
/// SM Callback that traces the rooted reflectors
pub unsafe fn trace_roots(tracer: *mut JSTracer) {
debug!("tracing stack roots");
STACK_ROOTS.with(|ref collection| {
STACK_ROOTS.with(|collection| {
let collection = &*(*collection.get().unwrap()).roots.get();
for root in collection {
(**root).trace(tracer);

View file

@ -275,7 +275,7 @@ impl DOMString {
'2' => State::HourLow03,
_ => State::Error,
},
State::HourLow09 => next_state(c.is_digit(10), State::MinuteColon),
State::HourLow09 => next_state(c.is_ascii_digit(), State::MinuteColon),
State::HourLow03 => next_state(c.is_digit(4), State::MinuteColon),
// Step 2 ":"
@ -283,20 +283,20 @@ impl DOMString {
// Step 3 "mm"
State::MinuteHigh => next_state(c.is_digit(6), State::MinuteLow),
State::MinuteLow => next_state(c.is_digit(10), State::SecondColon),
State::MinuteLow => next_state(c.is_ascii_digit(), State::SecondColon),
// Step 4.1 ":"
State::SecondColon => next_state(c == ':', State::SecondHigh),
// Step 4.2 "ss"
State::SecondHigh => next_state(c.is_digit(6), State::SecondLow),
State::SecondLow => next_state(c.is_digit(10), State::MilliStop),
State::SecondLow => next_state(c.is_ascii_digit(), State::MilliStop),
// Step 4.3.1 "."
State::MilliStop => next_state(c == '.', State::MilliHigh),
// Step 4.3.2 "SSS"
State::MilliHigh => next_state(c.is_digit(10), State::MilliMiddle),
State::MilliMiddle => next_state(c.is_digit(10), State::MilliLow),
State::MilliLow => next_state(c.is_digit(10), State::Done),
State::MilliHigh => next_state(c.is_ascii_digit(), State::MilliMiddle),
State::MilliMiddle => next_state(c.is_ascii_digit(), State::MilliLow),
State::MilliLow => next_state(c.is_ascii_digit(), State::Done),
_ => State::Error,
}