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> {
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 }
You can’t perform that action at this time.
0 commit comments