Replace loop with drop_in_place call

This commit is contained in:
est31 2020-09-17 17:20:22 +02:00
parent 5acfcceb47
commit daccd1709e

View file

@ -66,12 +66,7 @@ unsafe fn destroy(&mut self, len: usize) {
// The branch on needs_drop() is an -O1 performance optimization.
// Without the branch, dropping TypedArena<u8> takes linear time.
if mem::needs_drop::<T>() {
let mut start = self.start();
// Destroy all allocated objects.
for _ in 0..len {
ptr::drop_in_place(start);
start = start.offset(1);
}
ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(&mut self.storage[..len]));
}
}