This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -250,25 +250,20 @@ impl<T> TypedArena<T> {
250
250
available_bytes >= additional_bytes
251
251
}
252
252
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
-
262
253
#[ inline]
263
254
unsafe fn alloc_raw_slice ( & self , len : usize ) -> * mut T {
264
255
assert ! ( mem:: size_of:: <T >( ) != 0 ) ;
265
256
assert ! ( len != 0 ) ;
266
257
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
+ }
268
263
269
264
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.
272
267
unsafe { self . ptr . set ( start_ptr. add ( len) ) } ;
273
268
start_ptr
274
269
}
You can’t perform that action at this time.
0 commit comments