From a176a870987f61b04e001a7c4d0863fdeb427083 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 18 Dec 2024 13:38:49 -0800 Subject: [PATCH] Simplify extend_impl --- src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 42c04c3..e0f7328 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1502,11 +1502,11 @@ impl SmallVec { let mut iter = iter.fuse(); let (lower_bound, _) = iter.size_hint(); self.reserve(lower_bound); - let mut len = self.len(); let mut capacity = self.capacity(); let mut ptr = self.as_mut_ptr(); unsafe { loop { + let mut len = self.len(); // SAFETY: ptr is valid for `capacity - len` writes ptr = ptr.add(len); let mut guard = DropGuard { ptr, len: 0 }; @@ -1520,7 +1520,6 @@ impl SmallVec { // At this point we either consumed all capacity or the iterator is exhausted (fused) if let Some(item) = iter.next() { self.push(item); - len += 1; } else { return; }