diff options
| author | est31 <MTest31@outlook.com> | 2020-09-17 17:20:22 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2020-09-18 04:49:02 +0200 |
| commit | daccd1709ef1913e23d1b2f15dfeb16ac6e70ed8 (patch) | |
| tree | 45cb87906f4ee69d77d4aa42d856ad63e7559dcb | |
| parent | 5acfcceb47609862bba7035cf1cbfd807918dd36 (diff) | |
| download | rust-daccd1709ef1913e23d1b2f15dfeb16ac6e70ed8.tar.gz rust-daccd1709ef1913e23d1b2f15dfeb16ac6e70ed8.zip | |
Replace loop with drop_in_place call
| -rw-r--r-- | compiler/rustc_arena/src/lib.rs | 7 |
1 files changed, 1 insertions, 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<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])); } } |
