mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-02 03:02:54 -04:00
**What type of PR is this?** Optimisation **What does this PR do? Why is it needed?** Use `InitializeFromProtoUnsafeXXX` instead of `InitializeFromProtoXXX` when possible. (@nisdas' change) This change avoids useless copies. The difference between these two methods is the latest copies the input state. However, if the input state is guaranteed not to be modified after the use of this function (and, in particular, if the input state is not used at all after the use of this function), then copying it is unnecessarry. ==> Using the "unsafe" method is fine in this case. **Other notes for review** As a reviewer, you should ensure that when the unsafe method is used, then the input state is never modified after the use of the function. This PR is much easier to review directly in VSCode, because it displays more context by default. **Acknowledgements** - [x] I have read [CONTRIBUTING.md](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md). - [x] I have included a uniquely named [changelog fragment file](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md#maintaining-changelogmd). - [x] I have added a description with sufficient context for reviewers to understand this PR. - [x] I have tested that my changes work as expected and I added a testing plan to the PR description (if applicable).