From daccd1709ef1913e23d1b2f15dfeb16ac6e70ed8 Mon Sep 17 00:00:00 2001 From: est31 Date: Thu, 17 Sep 2020 17:20:22 +0200 Subject: [PATCH] Replace loop with drop_in_place call --- compiler/rustc_arena/src/lib.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index 2edf822cdb1..0d0b1efd2de 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -66,12 +66,7 @@ impl TypedArenaChunk { // The branch on needs_drop() is an -O1 performance optimization. // Without the branch, dropping TypedArena takes linear time. if mem::needs_drop::() { - 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])); } }