diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-09-20 07:32:12 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-09-28 15:44:48 +1000 |
| commit | 55de23ed5dff82a300cf379c9c756f82df48a987 (patch) | |
| tree | e945dfafed73faa50d77aa1b4722d759b125bcad | |
| parent | 0001eddb933ff9e5beeb8dd00c507b7abbd85e94 (diff) | |
Inline and remove `TypedArena::ensure_capacity`.
It has a single callsite.
| -rw-r--r-- | compiler/rustc_arena/src/lib.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index 0712f1efd64..a8a4ad89c4f 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -250,25 +250,20 @@ impl<T> TypedArena<T> { available_bytes >= additional_bytes } - /// Ensures there's enough space in the current chunk to fit `len` objects. - #[inline] - fn ensure_capacity(&self, additional: usize) { - if !self.can_allocate(additional) { - self.grow(additional); - debug_assert!(self.can_allocate(additional)); - } - } - #[inline] unsafe fn alloc_raw_slice(&self, len: usize) -> *mut T { assert!(mem::size_of::<T>() != 0); assert!(len != 0); - self.ensure_capacity(len); + // Ensure the current chunk can fit `len` objects. + if !self.can_allocate(len) { + self.grow(len); + debug_assert!(self.can_allocate(len)); + } let start_ptr = self.ptr.get(); - // SAFETY: `self.ensure_capacity` makes sure that there is enough space - // for `len` elements. + // SAFETY: `can_allocate`/`grow` ensures that there is enough space for + // `len` elements. unsafe { self.ptr.set(start_ptr.add(len)) }; start_ptr } |
