clippy: Fix len_zero warnings (#31935)

This commit is contained in:
Oluwatobi Sofela 2024-03-29 11:05:20 +01:00 committed by GitHub
parent 49c6b2668f
commit c3b6d40f90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 7 deletions

View file

@ -222,7 +222,7 @@ impl DOMString {
/// Removes leading and trailing ASCII whitespaces according to /// Removes leading and trailing ASCII whitespaces according to
/// <https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace>. /// <https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace>.
pub fn strip_leading_and_trailing_ascii_whitespace(&mut self) { pub fn strip_leading_and_trailing_ascii_whitespace(&mut self) {
if self.0.len() == 0 { if self.0.is_empty() {
return; return;
} }

View file

@ -1881,7 +1881,7 @@ impl HTMLInputElement {
} else { } else {
let opt_test_path = match opt_test_paths { let opt_test_path = match opt_test_paths {
Some(paths) => { Some(paths) => {
if paths.len() == 0 { if paths.is_empty() {
return; return;
} else { } else {
Some(paths[0].to_string()) // neglect other paths Some(paths[0].to_string()) // neglect other paths

View file

@ -213,7 +213,7 @@ impl Performance {
let buffer = self.buffer.borrow(); let buffer = self.buffer.borrow();
let mut new_entries = let mut new_entries =
buffer.get_entries_by_name_and_type(None, Some(entry_type.clone())); buffer.get_entries_by_name_and_type(None, Some(entry_type.clone()));
if new_entries.len() > 0 { if !new_entries.is_empty() {
let mut obs_entries = observer.entries(); let mut obs_entries = observer.entries();
obs_entries.append(&mut new_entries); obs_entries.append(&mut new_entries);
observer.set_entries(obs_entries); observer.set_entries(obs_entries);
@ -408,7 +408,7 @@ impl PerformanceMethods for Performance {
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#performance-timing-attribute // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#performance-timing-attribute
fn Timing(&self) -> DomRoot<PerformanceNavigationTiming> { fn Timing(&self) -> DomRoot<PerformanceNavigationTiming> {
let entries = self.GetEntriesByType(DOMString::from("navigation")); let entries = self.GetEntriesByType(DOMString::from("navigation"));
if entries.len() > 0 { if !entries.is_empty() {
return DomRoot::from_ref( return DomRoot::from_ref(
entries[0] entries[0]
.downcast::<PerformanceNavigationTiming>() .downcast::<PerformanceNavigationTiming>()

View file

@ -4136,7 +4136,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
Float32ArrayOrUnrestrictedFloatSequence::Float32Array(v) => v.to_vec(), Float32ArrayOrUnrestrictedFloatSequence::Float32Array(v) => v.to_vec(),
Float32ArrayOrUnrestrictedFloatSequence::UnrestrictedFloatSequence(v) => v, Float32ArrayOrUnrestrictedFloatSequence::UnrestrictedFloatSequence(v) => v,
}; };
if values.len() < 1 { if values.is_empty() {
// https://github.com/KhronosGroup/WebGL/issues/2700 // https://github.com/KhronosGroup/WebGL/issues/2700
return self.webgl_error(InvalidValue); return self.webgl_error(InvalidValue);
} }

View file

@ -721,7 +721,7 @@ impl ModuleTree {
match specifier_urls { match specifier_urls {
// Step 3. // Step 3.
Ok(valid_specifier_urls) if valid_specifier_urls.len() == 0 => { Ok(valid_specifier_urls) if valid_specifier_urls.is_empty() => {
debug!("Module {} doesn't have any dependencies.", self.url.clone()); debug!("Module {} doesn't have any dependencies.", self.url.clone());
self.advance_finished_and_link(&global); self.advance_finished_and_link(&global);
}, },
@ -746,7 +746,7 @@ impl ModuleTree {
} }
// Step 3. // Step 3.
if urls.len() == 0 { if urls.is_empty() {
debug!( debug!(
"After checking with visited urls, module {} doesn't have dependencies to load.", "After checking with visited urls, module {} doesn't have dependencies to load.",
self.url.clone() self.url.clone()