Skip to content

Commit 68fab81

Browse files
committed
refactor(allocator): rename inner Vec type (#8566)
Pure refactor. Using a named type `InnerVec` is clearer than having `Vec` and `vec::Vec` (which `Vec` is which?).
1 parent 5a28d68 commit 68fab81

File tree

1 file changed

+9
-9
lines changed
  • crates/oxc_allocator/src

1 file changed

+9
-9
lines changed

crates/oxc_allocator/src/vec.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{
1212
slice::SliceIndex,
1313
};
1414

15-
use allocator_api2::vec;
15+
use allocator_api2::vec::Vec as InnerVec;
1616
use bumpalo::Bump;
1717
#[cfg(any(feature = "serialize", test))]
1818
use serde::{ser::SerializeSeq, Serialize, Serializer};
@@ -29,7 +29,7 @@ use crate::{Allocator, Box, String};
2929
/// Note: This is not a soundness issue, as Rust does not support relying on `drop`
3030
/// being called to guarantee soundness.
3131
#[derive(PartialEq, Eq)]
32-
pub struct Vec<'alloc, T>(ManuallyDrop<vec::Vec<T, &'alloc Bump>>);
32+
pub struct Vec<'alloc, T>(ManuallyDrop<InnerVec<T, &'alloc Bump>>);
3333

3434
/// SAFETY: Not actually safe, but for enabling `Send` for downstream crates.
3535
unsafe impl<T> Send for Vec<'_, T> {}
@@ -53,7 +53,7 @@ impl<'alloc, T> Vec<'alloc, T> {
5353
/// ```
5454
#[inline]
5555
pub fn new_in(allocator: &'alloc Allocator) -> Self {
56-
Self(ManuallyDrop::new(vec::Vec::new_in(allocator)))
56+
Self(ManuallyDrop::new(InnerVec::new_in(allocator)))
5757
}
5858

5959
/// Constructs a new, empty `Vec<T>` with at least the specified capacity
@@ -105,7 +105,7 @@ impl<'alloc, T> Vec<'alloc, T> {
105105
/// ```
106106
#[inline]
107107
pub fn with_capacity_in(capacity: usize, allocator: &'alloc Allocator) -> Self {
108-
Self(ManuallyDrop::new(vec::Vec::with_capacity_in(capacity, allocator)))
108+
Self(ManuallyDrop::new(InnerVec::with_capacity_in(capacity, allocator)))
109109
}
110110

111111
/// Create a new [`Vec`] whose elements are taken from an iterator and
@@ -117,7 +117,7 @@ impl<'alloc, T> Vec<'alloc, T> {
117117
let iter = iter.into_iter();
118118
let hint = iter.size_hint();
119119
let capacity = hint.1.unwrap_or(hint.0);
120-
let mut vec = ManuallyDrop::new(vec::Vec::with_capacity_in(capacity, &**allocator));
120+
let mut vec = ManuallyDrop::new(InnerVec::with_capacity_in(capacity, &**allocator));
121121
vec.extend(iter);
122122
Self(vec)
123123
}
@@ -146,7 +146,7 @@ impl<'alloc, T> Vec<'alloc, T> {
146146
// `ptr` was allocated with correct size for `[T; N]`.
147147
// `len` and `capacity` are both `N`.
148148
// Allocated size cannot be larger than `isize::MAX`, or `Box::new_in` would have failed.
149-
let vec = unsafe { vec::Vec::from_raw_parts_in(ptr, N, N, &**allocator) };
149+
let vec = unsafe { InnerVec::from_raw_parts_in(ptr, N, N, &**allocator) };
150150
Self(ManuallyDrop::new(vec))
151151
}
152152

@@ -218,21 +218,21 @@ impl<'alloc> Vec<'alloc, u8> {
218218
}
219219

220220
impl<'alloc, T> ops::Deref for Vec<'alloc, T> {
221-
type Target = vec::Vec<T, &'alloc Bump>;
221+
type Target = InnerVec<T, &'alloc Bump>;
222222

223223
fn deref(&self) -> &Self::Target {
224224
&self.0
225225
}
226226
}
227227

228228
impl<'alloc, T> ops::DerefMut for Vec<'alloc, T> {
229-
fn deref_mut(&mut self) -> &mut vec::Vec<T, &'alloc Bump> {
229+
fn deref_mut(&mut self) -> &mut InnerVec<T, &'alloc Bump> {
230230
&mut self.0
231231
}
232232
}
233233

234234
impl<'alloc, T> IntoIterator for Vec<'alloc, T> {
235-
type IntoIter = <vec::Vec<T, &'alloc Bump> as IntoIterator>::IntoIter;
235+
type IntoIter = <InnerVec<T, &'alloc Bump> as IntoIterator>::IntoIter;
236236
type Item = T;
237237

238238
fn into_iter(self) -> Self::IntoIter {

0 commit comments

Comments
 (0)