Skip to content

Commit 48cb20e

Browse files
committed
remove reserve_for_push
1 parent 736c675 commit 48cb20e

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

library/alloc/src/raw_vec.rs

-8
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,6 @@ impl<T, A: Allocator> RawVec<T, A> {
290290
}
291291
}
292292

293-
/// A specialized version of `reserve()` used only by the hot and
294-
/// oft-instantiated `Vec::push()`, which does its own capacity check.
295-
#[cfg(not(no_global_oom_handling))]
296-
#[inline(never)]
297-
pub fn reserve_for_push(&mut self, len: usize) {
298-
handle_reserve(self.grow_amortized(len, 1));
299-
}
300-
301293
/// The same as `reserve`, but returns on errors instead of panicking or aborting.
302294
pub fn try_reserve(&mut self, len: usize, additional: usize) -> Result<(), TryReserveError> {
303295
if self.needs_to_grow(len, additional) {

library/alloc/src/vec/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1830,9 +1830,7 @@ impl<T, A: Allocator> Vec<T, A> {
18301830
pub fn push(&mut self, value: T) {
18311831
// This will panic or abort if we would allocate > isize::MAX bytes
18321832
// or if the length increment would overflow for zero-sized types.
1833-
if self.len == self.buf.capacity() {
1834-
self.buf.reserve_for_push(self.len);
1835-
}
1833+
self.buf.reserve(self.len, 1);
18361834
unsafe {
18371835
let end = self.as_mut_ptr().add(self.len);
18381836
ptr::write(end, value);

0 commit comments

Comments
 (0)