Skip to content

Commit aee40df

Browse files
committed
Rename reserve_for_push to grow_one and fix comment.
1 parent 10fa6ea commit aee40df

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

alloc/src/collections/vec_deque/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
20872087
// buffer without it being full emerge
20882088
debug_assert!(self.is_full());
20892089
let old_cap = self.capacity();
2090-
self.buf.reserve_for_push();
2090+
self.buf.grow_one();
20912091
unsafe {
20922092
self.handle_capacity_increase(old_cap);
20932093
}

alloc/src/raw_vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,11 @@ impl<T, A: Allocator> RawVec<T, A> {
345345
}
346346
}
347347

348-
/// A specialized version of `reserve()` used only by the hot and
349-
/// oft-instantiated `Vec::push()`, which does its own capacity check.
348+
/// A specialized version of `self.reserve(len, 1)` which requires the
349+
/// caller to ensure `len == self.capacity()`.
350350
#[cfg(not(no_global_oom_handling))]
351351
#[inline(never)]
352-
pub fn reserve_for_push(&mut self) {
352+
pub fn grow_one(&mut self) {
353353
if let Err(err) = self.grow_amortized(self.cap.0, 1) {
354354
handle_error(err);
355355
}

alloc/src/vec/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ impl<T, A: Allocator> Vec<T, A> {
15471547

15481548
// space for the new element
15491549
if len == self.buf.capacity() {
1550-
self.buf.reserve_for_push();
1550+
self.buf.grow_one();
15511551
}
15521552

15531553
unsafe {
@@ -1967,7 +1967,7 @@ impl<T, A: Allocator> Vec<T, A> {
19671967
// This will panic or abort if we would allocate > isize::MAX bytes
19681968
// or if the length increment would overflow for zero-sized types.
19691969
if self.len == self.buf.capacity() {
1970-
self.buf.reserve_for_push();
1970+
self.buf.grow_one();
19711971
}
19721972
unsafe {
19731973
let end = self.as_mut_ptr().add(self.len);

0 commit comments

Comments
 (0)