Skip to content

Commit 42f909a

Browse files
committed
1 parent 138fd56 commit 42f909a

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

library/alloc/src/raw_vec.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -315,24 +315,8 @@ impl<T, A: Allocator> RawVec<T, A> {
315315
/// # vector.push_all(&[1, 3, 5, 7, 9]);
316316
/// # }
317317
/// ```
318-
#[inline]
319318
pub fn reserve(&mut self, len: usize, additional: usize) {
320-
// Callers expect this function to be very cheap when there is already sufficient capacity.
321-
// Therefore, we move all the resizing and error-handling logic from grow_amortized and
322-
// handle_reserve behind a call, while making sure that the this function is likely to be
323-
// inlined as just a comparison and a call if the comparison fails.
324-
#[cold]
325-
fn do_reserve_and_handle<T, A: Allocator>(
326-
slf: &mut RawVec<T, A>,
327-
len: usize,
328-
additional: usize,
329-
) {
330-
handle_reserve(slf.grow_amortized(len, additional));
331-
}
332-
333-
if self.needs_to_grow(len, additional) {
334-
do_reserve_and_handle(self, len, additional);
335-
}
319+
handle_reserve(self.try_reserve(len, additional));
336320
}
337321

338322
/// The same as `reserve`, but returns on errors instead of panicking or aborting.

0 commit comments

Comments
 (0)