Skip to content

Commit

Permalink
Replace loop with drop_in_place call
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Sep 18, 2020
1 parent 5acfcce commit daccd17
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions compiler/rustc_arena/src/lib.rs
Expand Up @@ -66,12 +66,7 @@ impl<T> TypedArenaChunk<T> {
// 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]));
}
}

Expand Down

0 comments on commit daccd17

Please sign in to comment.