From 18d390883efc7eaf5ced77d89abc5b51c8b7f816 Mon Sep 17 00:00:00 2001 From: Cai Bear Date: Sat, 23 Mar 2024 21:27:59 -0700 Subject: Remove len argument from RawVec::reserve_for_push because it's always equal to capacity. Also make Vec::insert use reserve_for_push. --- library/alloc/src/vec/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'library/alloc/src/vec') 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 Vec { // space for the new element if len == self.buf.capacity() { - self.reserve(1); + self.buf.reserve_for_push(); } unsafe { @@ -1967,7 +1967,7 @@ impl Vec { // 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); -- cgit 1.4.1-3-g733a5