From bec8feecf20070d4f2a00aa5397c5b535fde7d4f Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 5 Feb 2025 16:17:30 +0000 Subject: [PATCH] refactor(data_structures)!: rename `Stack::last_unchecked_mut` method (#8911) Rename `Stack::last_mut_unchecked` to `Stack::last_unchecked_mut`. This matches `std`'s naming convention e.g. `get_unchecked_mut` on slices. --- crates/oxc_data_structures/src/stack/sparse.rs | 4 ++-- crates/oxc_data_structures/src/stack/standard.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/oxc_data_structures/src/stack/sparse.rs b/crates/oxc_data_structures/src/stack/sparse.rs index 5e6f07c227a1d..4bb07dc6f76da 100644 --- a/crates/oxc_data_structures/src/stack/sparse.rs +++ b/crates/oxc_data_structures/src/stack/sparse.rs @@ -177,7 +177,7 @@ impl SparseStack { debug_assert!(!self.values.is_empty()); // SAFETY: Last `self.has_values` is only `true` if there's a corresponding value in `self.values`. // This invariant is maintained in `push`, `pop`, `take_last`, `last_or_init`, and `last_mut_or_init`. - let value = unsafe { self.values.last_mut_unchecked() }; + let value = unsafe { self.values.last_unchecked_mut() }; Some(value) } else { None @@ -236,7 +236,7 @@ impl SparseStack { // This invariant is maintained in `push`, `pop`, `take_last`, and `last_or_init`. // Here either last `self.has_values` was already `true`, or it's just been set to `true` // and a value pushed to `self.values` above. - unsafe { self.values.last_mut_unchecked() } + unsafe { self.values.last_unchecked_mut() } } /// Get number of entries on the stack. diff --git a/crates/oxc_data_structures/src/stack/standard.rs b/crates/oxc_data_structures/src/stack/standard.rs index 0e238b127b1d4..115e59eeb5d74 100644 --- a/crates/oxc_data_structures/src/stack/standard.rs +++ b/crates/oxc_data_structures/src/stack/standard.rs @@ -224,7 +224,7 @@ impl Stack { #[expect(clippy::if_not_else)] if !self.is_empty() { // SAFETY: Stack is not empty - Some(unsafe { self.last_mut_unchecked() }) + Some(unsafe { self.last_unchecked_mut() }) } else { None } @@ -236,7 +236,7 @@ impl Stack { /// /// * Stack must not be empty. #[inline] - pub unsafe fn last_mut_unchecked(&mut self) -> &mut T { + pub unsafe fn last_unchecked_mut(&mut self) -> &mut T { debug_assert!(self.end > self.start); debug_assert!(self.cursor > self.start); debug_assert!(self.cursor <= self.end);