Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 55de23e

Browse files
committed
Inline and remove TypedArena::ensure_capacity.
It has a single callsite.
1 parent 0001edd commit 55de23e

File tree

1 file changed

+7
-12
lines changed
  • compiler/rustc_arena/src

1 file changed

+7
-12
lines changed

compiler/rustc_arena/src/lib.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,25 +250,20 @@ impl<T> TypedArena<T> {
250250
available_bytes >= additional_bytes
251251
}
252252

253-
/// Ensures there's enough space in the current chunk to fit `len` objects.
254-
#[inline]
255-
fn ensure_capacity(&self, additional: usize) {
256-
if !self.can_allocate(additional) {
257-
self.grow(additional);
258-
debug_assert!(self.can_allocate(additional));
259-
}
260-
}
261-
262253
#[inline]
263254
unsafe fn alloc_raw_slice(&self, len: usize) -> *mut T {
264255
assert!(mem::size_of::<T>() != 0);
265256
assert!(len != 0);
266257

267-
self.ensure_capacity(len);
258+
// Ensure the current chunk can fit `len` objects.
259+
if !self.can_allocate(len) {
260+
self.grow(len);
261+
debug_assert!(self.can_allocate(len));
262+
}
268263

269264
let start_ptr = self.ptr.get();
270-
// SAFETY: `self.ensure_capacity` makes sure that there is enough space
271-
// for `len` elements.
265+
// SAFETY: `can_allocate`/`grow` ensures that there is enough space for
266+
// `len` elements.
272267
unsafe { self.ptr.set(start_ptr.add(len)) };
273268
start_ptr
274269
}

0 commit comments

Comments
 (0)