mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-21 06:12:23 +00:00
Improve fill_zeroes
' use of ptr::write_bytes
(#284)
This commit is contained in:
parent
13f4ae0cdf
commit
1400815a33
@ -532,8 +532,8 @@ pub fn fill_zeroes<T: Zeroable>(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) }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user