diff options
| author | Cai Bear <git@caibear.com> | 2024-03-23 21:27:59 -0700 |
|---|---|---|
| committer | Cai Bear <git@caibear.com> | 2024-03-28 16:21:54 -0700 |
| commit | 18d390883efc7eaf5ced77d89abc5b51c8b7f816 (patch) | |
| tree | 486fc19f7b562890eb3f8fe8f96877e8e5324c13 /library/alloc/src/vec/mod.rs | |
| parent | ba527200cce74e0b752927f5fd071d06fd9d0962 (diff) | |
| download | rust-18d390883efc7eaf5ced77d89abc5b51c8b7f816.tar.gz rust-18d390883efc7eaf5ced77d89abc5b51c8b7f816.zip | |
Remove len argument from RawVec::reserve_for_push because it's always equal to capacity. Also make Vec::insert use reserve_for_push.
Diffstat (limited to 'library/alloc/src/vec/mod.rs')
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 8ca8046dac5..5f4c45d578d 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.reserve(1); + self.buf.reserve_for_push(); } 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.len); + self.buf.reserve_for_push(); } unsafe { let end = self.as_mut_ptr().add(self.len); |
