Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace for loop with [u8]::fill method #38

Closed
joshlf opened this issue Oct 9, 2022 · 2 comments · Fixed by #41
Closed

Replace for loop with [u8]::fill method #38

joshlf opened this issue Oct 9, 2022 · 2 comments · Fixed by #41
Assignees

Comments

@joshlf
Copy link
Member

joshlf commented Oct 9, 2022

In map_zeroed and map_prefix_tuple_zeroed, we zero a byte slice by doing:

for b in lv.0.iter_mut() {
    *b = 0;
}

Instead, we could use [u8]::fill:

lv.0.fill(0);
@MSalah73
Copy link
Contributor

I'll take this one

@joshlf
Copy link
Member Author

joshlf commented Oct 10, 2022

Awesome, thanks @MSalah73! Welcome to zerocopy 😃

MSalah73 added a commit to MSalah73/zerocopy that referenced this issue Oct 10, 2022
Refactored map_zeroed & map_prefix_tuple_zeroed's for-loops with the [u8]::fill method.

Resloves google#38
MSalah73 added a commit to MSalah73/zerocopy that referenced this issue Oct 10, 2022
Refactored map_zeroed & map_prefix_tuple_zeroed's for-loops with the [u8]::fill method.

Resolves google#38
joshlf pushed a commit that referenced this issue Oct 10, 2022
Refactor map_zeroed & map_prefix_tuple_zeroed's for loops with the
`[u8]::fill` method.

Resolves #38
joshlf pushed a commit that referenced this issue Aug 3, 2023
Refactor map_zeroed & map_prefix_tuple_zeroed's for loops with the
`[u8]::fill` method.

Resolves #38
@joshlf joshlf mentioned this issue Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants