Skip to content

Commit

Permalink
Refactor zeroing for loops with the [u8]::fill method
Browse files Browse the repository at this point in the history
Refactored map_zeroed & map_prefix_tuple_zeroed's for-loops with the [u8]::fill method.

Resloves google#38
  • Loading branch information
MSalah73 committed Oct 10, 2022
1 parent 49fc9ff commit 3d24859
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,9 +1041,7 @@ fn map_zeroed<B: ByteSliceMut, T: ?Sized>(
) -> Option<LayoutVerified<B, T>> {
match opt {
Some(mut lv) => {
for b in lv.0.iter_mut() {
*b = 0;
}
lv.0.fill(0);
Some(lv)
}
None => None,
Expand All @@ -1055,9 +1053,7 @@ fn map_prefix_tuple_zeroed<B: ByteSliceMut, T: ?Sized>(
) -> Option<(LayoutVerified<B, T>, B)> {
match opt {
Some((mut lv, rest)) => {
for b in lv.0.iter_mut() {
*b = 0;
}
lv.0.fill(0);
Some((lv, rest))
}
None => None,
Expand Down

0 comments on commit 3d24859

Please sign in to comment.