mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Replace loop with drop_in_place call
This commit is contained in:
parent
5acfcceb47
commit
daccd1709e
@ -66,12 +66,7 @@ impl<T> TypedArenaChunk<T> {
|
|||||||
// The branch on needs_drop() is an -O1 performance optimization.
|
// The branch on needs_drop() is an -O1 performance optimization.
|
||||||
// Without the branch, dropping TypedArena<u8> takes linear time.
|
// Without the branch, dropping TypedArena<u8> takes linear time.
|
||||||
if mem::needs_drop::<T>() {
|
if mem::needs_drop::<T>() {
|
||||||
let mut start = self.start();
|
ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(&mut self.storage[..len]));
|
||||||
// Destroy all allocated objects.
|
|
||||||
for _ in 0..len {
|
|
||||||
ptr::drop_in_place(start);
|
|
||||||
start = start.offset(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user