From 1400815a33d28754d619000fe65d5f492fd1ead5 Mon Sep 17 00:00:00 2001 From: Alphyr <47725341+a1phyr@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:01:37 +0100 Subject: [PATCH] Improve `fill_zeroes`' use of `ptr::write_bytes` (#284) --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2d7f270..a3700d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -532,8 +532,8 @@ pub fn fill_zeroes(slice: &mut [T]) { slice.iter_mut().for_each(write_zeroes); } else { // Otherwise we can be really fast and just fill everthing with zeros. - let len = core::mem::size_of_val::<[T]>(slice); - unsafe { core::ptr::write_bytes(slice.as_mut_ptr() as *mut u8, 0u8, len) } + let len = slice.len(); + unsafe { core::ptr::write_bytes(slice.as_mut_ptr(), 0u8, len) } } }