fix: optimize MaybeUninit array initialization in keccak256_round_function #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What ❔
Optimizes the initialization of an array using
[MaybeUninit<_>; _]
. This is recommended in std docs and it just simplifies the asm and reduces instructions. I don't believe Rust can optimize away the fact that this would initialize a new array and copy the elements over. I've included the asm of this code in isolation to give an idea.asm diff
Why ❔
I was reading the code to understand what this was doing and noticed this. Seemed like an unopinionated improvement, unless I'm missing something here.
Checklist
zk fmt
andzk lint
.cargo fmt
and checked clippy to make sure there were no warnings in the changed code. Assume this is related to https://github.com/matter-labs/zksync-era/tree/1e30d0ba8d243f41ad1e86e77d24848d64bd11e6/infrastructure/zk, but I'm assuming here that this template is copied or outdated.