Skip to content

Commit b24b3d2

Browse files
committed
Use a single ptr::drop_in_place call instead of a loop
This is what the standard Vec does; see rust-lang/rust#32012.
1 parent 73b24b4 commit b24b3d2

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,10 +1186,7 @@ impl<A: Array> Drop for SmallVec<A> {
11861186
let (ptr, len) = self.data.heap();
11871187
Vec::from_raw_parts(ptr, len, self.capacity);
11881188
} else {
1189-
let ptr = self.as_mut_ptr();
1190-
for i in 0..self.len() {
1191-
ptr::drop_in_place(ptr.offset(i as isize));
1192-
}
1189+
ptr::drop_in_place(&mut self[..]);
11931190
}
11941191
}
11951192
}

0 commit comments

Comments
 (0)