Rename reserve_for_push to grow_one and fix comment.
This commit is contained in:
parent
78dc89b0d5
commit
aba592d09c
@ -2087,7 +2087,7 @@ fn grow(&mut self) {
|
||||
// buffer without it being full emerge
|
||||
debug_assert!(self.is_full());
|
||||
let old_cap = self.capacity();
|
||||
self.buf.reserve_for_push();
|
||||
self.buf.grow_one();
|
||||
unsafe {
|
||||
self.handle_capacity_increase(old_cap);
|
||||
}
|
||||
|
@ -345,11 +345,11 @@ fn do_reserve_and_handle<T, A: Allocator>(
|
||||
}
|
||||
}
|
||||
|
||||
/// A specialized version of `reserve()` used only by the hot and
|
||||
/// oft-instantiated `Vec::push()`, which does its own capacity check.
|
||||
/// A specialized version of `self.reserve(len, 1)` which requires the
|
||||
/// caller to ensure `len == self.capacity()`.
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[inline(never)]
|
||||
pub fn reserve_for_push(&mut self) {
|
||||
pub fn grow_one(&mut self) {
|
||||
if let Err(err) = self.grow_amortized(self.cap.0, 1) {
|
||||
handle_error(err);
|
||||
}
|
||||
|
@ -1547,7 +1547,7 @@ fn assert_failed(index: usize, len: usize) -> ! {
|
||||
|
||||
// space for the new element
|
||||
if len == self.buf.capacity() {
|
||||
self.buf.reserve_for_push();
|
||||
self.buf.grow_one();
|
||||
}
|
||||
|
||||
unsafe {
|
||||
@ -1967,7 +1967,7 @@ pub fn push(&mut self, value: T) {
|
||||
// This will panic or abort if we would allocate > isize::MAX bytes
|
||||
// or if the length increment would overflow for zero-sized types.
|
||||
if self.len == self.buf.capacity() {
|
||||
self.buf.reserve_for_push();
|
||||
self.buf.grow_one();
|
||||
}
|
||||
unsafe {
|
||||
let end = self.as_mut_ptr().add(self.len);
|
||||
|
Loading…
Reference in New Issue
Block a user