From d4fc770e11a55385c6e11ce9fe7df3a5f3aa84f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20du=20Garreau?= Date: Wed, 6 Nov 2024 11:40:41 +0100 Subject: [PATCH] Improve `fill_zeroes`' use of `ptr::write_bytes` --- src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2d7f270..d65d0f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -532,8 +532,7 @@ 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) } + unsafe { core::ptr::write_bytes(slice.as_mut_ptr(), 0u8, slice.len()) } } }