-
Notifications
You must be signed in to change notification settings - Fork 407
Trivial ChaCha cleanups #2764
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
Trivial ChaCha cleanups #2764
Conversation
While its all constant arithmetic to calculate the shift, which LLVM likely optimizes out for us, there's no reason to do it four times, which just makes the code harder to read.
These are obviously super hot, and while LLVM shouldn't be braindead here you never know, so we might as well `#[inline]`.
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2764 +/- ##
=======================================
Coverage 88.57% 88.57%
=======================================
Files 115 115
Lines 89479 89479
Branches 89479 89479
=======================================
+ Hits 79258 79260 +2
+ Misses 7858 7852 -6
- Partials 2363 2367 +4 ☔ View full report in Codecov by Sentry. |
FYI, we copied this code in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review ACK
- Out of all occurrences of
>>
or<<
operation, there are no instances where any of the rotation matrix's u32x4 elements are different from each other. - In this case, it makes sense to simplify the code, making it easier to understand and reason with.
This PR is a definite improvement over the current code, and I feel like it's best to maintain consistency between the various codebases under LDK org. |
Yea, there's nothing wrong with the code, 90% chance LLVM optimizes it down into identical code anyway, but I just felt like updating it cause it was ugly :) |
Pretty trivial and this code should be hit in most tests as well, so I'll land. |
I was looking at this code and it bothered me.