From 7b5e1f5ac8f0f2952f4e4c72d0ea4cee2ca62346 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:42:05 +0000 Subject: [PATCH] refactor(semantic): use `is_empty()` instead of `len() == 0` (#4532) It's preferred to use `is_empty` where possible. `is_empty` is sometimes slightly more optimized than `len() == 0`. --- crates/oxc_semantic/src/node.rs | 2 +- crates/oxc_semantic/src/scope.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/oxc_semantic/src/node.rs b/crates/oxc_semantic/src/node.rs index 92df5a0fd..1ce686d90 100644 --- a/crates/oxc_semantic/src/node.rs +++ b/crates/oxc_semantic/src/node.rs @@ -87,7 +87,7 @@ impl<'a> AstNodes<'a> { #[inline] pub fn is_empty(&self) -> bool { - self.nodes.len() == 0 + self.nodes.is_empty() } /// Walk up the AST, iterating over each parent node. diff --git a/crates/oxc_semantic/src/scope.rs b/crates/oxc_semantic/src/scope.rs index 01d035d57..4592c972a 100644 --- a/crates/oxc_semantic/src/scope.rs +++ b/crates/oxc_semantic/src/scope.rs @@ -41,7 +41,7 @@ impl ScopeTree { #[inline] pub fn is_empty(&self) -> bool { - self.len() == 0 + self.parent_ids.is_empty() } pub fn ancestors(&self, scope_id: ScopeId) -> impl Iterator + '_ {