Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(data_structures): remove is_empty methods for non-empty stacks #6219

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/oxc_data_structures/src/stack/non_empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,12 @@ impl<T> NonEmptyStack<T> {
<Self as StackCommon<T>>::len(self)
}

/// Get if stack is empty. Always returns `false`.
#[inline]
pub fn is_empty(&self) -> bool {
self.len() == 0
// This method is pointless, as the stack is never empty. But provide it to override
// the default method from `slice::is_empty` which is inherited via `Deref`
false
}

/// Get capacity.
Expand Down
6 changes: 1 addition & 5 deletions crates/oxc_data_structures/src/stack/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,11 @@ impl<T> SparseStack<T> {
///
/// Number of entries is always at least 1. Stack is never empty.
#[inline]
#[expect(clippy::len_without_is_empty)] // `is_empty` method is pointless. It's never empty.
pub fn len(&self) -> usize {
self.has_values.len()
}

#[inline]
pub fn is_empty(&self) -> bool {
self.has_values.len() == 0
}

/// Get capacity of stack for any entries (either `Some` or `None`).
///
/// Capacity is always at least 1. Stack is never empty.
Expand Down
Loading