Skip to content

Commit

Permalink
refactor(semantic): use is_empty() instead of len() == 0 (#4532)
Browse files Browse the repository at this point in the history
It's preferred to use `is_empty` where possible. `is_empty` is sometimes slightly more optimized than `len() == 0`.
  • Loading branch information
overlookmotel committed Jul 29, 2024
1 parent 9db4259 commit 7b5e1f5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = ScopeId> + '_ {
Expand Down

0 comments on commit 7b5e1f5

Please sign in to comment.