Skip to content

Commit 7b5e1f5

Browse files
committed
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`.
1 parent 9db4259 commit 7b5e1f5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

crates/oxc_semantic/src/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a> AstNodes<'a> {
8787

8888
#[inline]
8989
pub fn is_empty(&self) -> bool {
90-
self.nodes.len() == 0
90+
self.nodes.is_empty()
9191
}
9292

9393
/// Walk up the AST, iterating over each parent node.

crates/oxc_semantic/src/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl ScopeTree {
4141

4242
#[inline]
4343
pub fn is_empty(&self) -> bool {
44-
self.len() == 0
44+
self.parent_ids.is_empty()
4545
}
4646

4747
pub fn ancestors(&self, scope_id: ScopeId) -> impl Iterator<Item = ScopeId> + '_ {

0 commit comments

Comments
 (0)