Skip to content

Commit

Permalink
Improve fill_zeroes' use of ptr::write_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Nov 19, 2024
1 parent 13f4ae0 commit 002072f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}

Expand Down

0 comments on commit 002072f

Please sign in to comment.