From b24b3d2f64038c1220d7875173fb9a095453359b Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 6 Jun 2018 09:31:40 -0700 Subject: [PATCH] Use a single ptr::drop_in_place call instead of a loop This is what the standard Vec does; see rust-lang/rust#32012. --- lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib.rs b/lib.rs index 9c24586..5ee40b7 100644 --- a/lib.rs +++ b/lib.rs @@ -1186,10 +1186,7 @@ impl Drop for SmallVec { let (ptr, len) = self.data.heap(); Vec::from_raw_parts(ptr, len, self.capacity); } else { - let ptr = self.as_mut_ptr(); - for i in 0..self.len() { - ptr::drop_in_place(ptr.offset(i as isize)); - } + ptr::drop_in_place(&mut self[..]); } } }