Skip to content

Commit daccd17

Browse files
committed
Replace loop with drop_in_place call
1 parent 5acfcce commit daccd17

File tree

1 file changed

+1
-6
lines changed
  • compiler/rustc_arena/src

1 file changed

+1
-6
lines changed

compiler/rustc_arena/src/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ impl<T> TypedArenaChunk<T> {
6666
// The branch on needs_drop() is an -O1 performance optimization.
6767
// Without the branch, dropping TypedArena<u8> takes linear time.
6868
if mem::needs_drop::<T>() {
69-
let mut start = self.start();
70-
// Destroy all allocated objects.
71-
for _ in 0..len {
72-
ptr::drop_in_place(start);
73-
start = start.offset(1);
74-
}
69+
ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(&mut self.storage[..len]));
7570
}
7671
}
7772

0 commit comments

Comments
 (0)