mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-24 07:42:24 +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);
|
slice.iter_mut().for_each(write_zeroes);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise we can be really fast and just fill everthing with zeros.
|
// Otherwise we can be really fast and just fill everthing with zeros.
|
||||||
let len = core::mem::size_of_val::<[T]>(slice);
|
let len = slice.len();
|
||||||
unsafe { core::ptr::write_bytes(slice.as_mut_ptr() as *mut u8, 0u8, len) }
|
unsafe { core::ptr::write_bytes(slice.as_mut_ptr(), 0u8, len) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user