Skip to content

Commit 1400815

Browse files
authored
Improve fill_zeroes' use of ptr::write_bytes (#284)
1 parent 13f4ae0 commit 1400815

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ pub fn fill_zeroes<T: Zeroable>(slice: &mut [T]) {
532532
slice.iter_mut().for_each(write_zeroes);
533533
} else {
534534
// Otherwise we can be really fast and just fill everthing with zeros.
535-
let len = core::mem::size_of_val::<[T]>(slice);
536-
unsafe { core::ptr::write_bytes(slice.as_mut_ptr() as *mut u8, 0u8, len) }
535+
let len = slice.len();
536+
unsafe { core::ptr::write_bytes(slice.as_mut_ptr(), 0u8, len) }
537537
}
538538
}
539539

0 commit comments

Comments
 (0)