diff options
| author | Cai Bear <git@caibear.com> | 2024-03-28 16:38:01 -0700 |
|---|---|---|
| committer | Cai Bear <git@caibear.com> | 2024-03-28 16:38:01 -0700 |
| commit | aba592d09c78fcf1432de24c200fffa2fb21aeb6 (patch) | |
| tree | 624eb8ae01612e268f002a5946366da74247c714 /library/alloc/src | |
| parent | 78dc89b0d5654bb16a63121c60198cbe24878289 (diff) | |
| download | rust-aba592d09c78fcf1432de24c200fffa2fb21aeb6.tar.gz rust-aba592d09c78fcf1432de24c200fffa2fb21aeb6.zip | |
Rename reserve_for_push to grow_one and fix comment.
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/collections/vec_deque/mod.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/raw_vec.rs | 6 | ||||
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index e1341c21af6..5ff7f184a6d 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -2087,7 +2087,7 @@ impl<T, A: Allocator> VecDeque<T, A> { // 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); } diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index 45258cc86ff..0883080d735 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -345,11 +345,11 @@ impl<T, A: Allocator> RawVec<T, A> { } } - /// 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); } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 5f4c45d578d..7e3463bc082 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1547,7 +1547,7 @@ impl<T, A: Allocator> Vec<T, A> { // space for the new element if len == self.buf.capacity() { - self.buf.reserve_for_push(); + self.buf.grow_one(); } unsafe { @@ -1967,7 +1967,7 @@ impl<T, A: Allocator> Vec<T, A> { // 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); |
