diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-01-26 01:35:52 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-01-26 01:35:52 +1100 |
| commit | 0c17893d498d30f8a86a97bbc1227852d5e926cd (patch) | |
| tree | 1671cc26872f5b5487b881ce1a67a48024805b42 | |
| parent | 84322efad553c7a79c80189f2d1b9197c1aa005f (diff) | |
| download | rust-0c17893d498d30f8a86a97bbc1227852d5e926cd.tar.gz rust-0c17893d498d30f8a86a97bbc1227852d5e926cd.zip | |
Rename `TypedArenaChunk` as `ArenaChunk`.
Because it's used within both `TypedArena` and `DroplessArena`. The commit also makes `<u8>` the default parameter.
| -rw-r--r-- | compiler/rustc_arena/src/lib.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index 6f9ecb9cd21..fb93fa152ac 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -45,24 +45,24 @@ pub struct TypedArena<T> { end: Cell<*mut T>, /// A vector of arena chunks. - chunks: RefCell<Vec<TypedArenaChunk<T>>>, + chunks: RefCell<Vec<ArenaChunk<T>>>, /// Marker indicating that dropping the arena causes its owned /// instances of `T` to be dropped. _own: PhantomData<T>, } -struct TypedArenaChunk<T> { +struct ArenaChunk<T = u8> { /// The raw storage for the arena chunk. storage: Box<[MaybeUninit<T>]>, /// The number of valid entries in the chunk. entries: usize, } -impl<T> TypedArenaChunk<T> { +impl<T> ArenaChunk<T> { #[inline] - unsafe fn new(capacity: usize) -> TypedArenaChunk<T> { - TypedArenaChunk { storage: Box::new_uninit_slice(capacity), entries: 0 } + unsafe fn new(capacity: usize) -> ArenaChunk<T> { + ArenaChunk { storage: Box::new_uninit_slice(capacity), entries: 0 } } /// Destroys this arena chunk. @@ -272,7 +272,7 @@ impl<T> TypedArena<T> { // Also ensure that this chunk can fit `additional`. new_cap = cmp::max(additional, new_cap); - let mut chunk = TypedArenaChunk::<T>::new(new_cap); + let mut chunk = ArenaChunk::<T>::new(new_cap); self.ptr.set(chunk.start()); self.end.set(chunk.end()); chunks.push(chunk); @@ -281,7 +281,7 @@ impl<T> TypedArena<T> { // Drops the contents of the last chunk. The last chunk is partially empty, unlike all other // chunks. - fn clear_last_chunk(&self, last_chunk: &mut TypedArenaChunk<T>) { + fn clear_last_chunk(&self, last_chunk: &mut ArenaChunk<T>) { // Determine how much was filled. let start = last_chunk.start() as usize; // We obtain the value of the pointer to the first uninitialized element. @@ -340,7 +340,7 @@ pub struct DroplessArena { end: Cell<*mut u8>, /// A vector of arena chunks. - chunks: RefCell<Vec<TypedArenaChunk<u8>>>, + chunks: RefCell<Vec<ArenaChunk>>, } unsafe impl Send for DroplessArena {} @@ -378,7 +378,7 @@ impl DroplessArena { // Also ensure that this chunk can fit `additional`. new_cap = cmp::max(additional, new_cap); - let mut chunk = TypedArenaChunk::<u8>::new(new_cap); + let mut chunk = ArenaChunk::new(new_cap); self.start.set(chunk.start()); self.end.set(chunk.end()); chunks.push(chunk); |
