-
Notifications
You must be signed in to change notification settings - Fork 715
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
Take some steps toward eliminating the last unsafe
in ring::polyfill
#1732
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1732 +/- ##
==========================================
+ Coverage 96.11% 96.12% +0.01%
==========================================
Files 136 137 +1
Lines 20521 20548 +27
Branches 217 217
==========================================
+ Hits 19723 19752 +29
Misses 760 760
+ Partials 38 36 -2
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@joshlf PTAL. This is mostly to start a discussion. Definitely I am curious about whether there's a simpler way of doing this. I was hoping the array_* standard library facilities would be available by now, but it seems unlikely that they will become stable soon. |
I don't have any strong opinions here, but the approach seems reasonable. Anything that removes |
f38f1e1
to
424b516
Compare
This is a step towards eliminating the `unsafe` code in `ChunksFixed`. chacha nonce
This is a step towards eliminating the `unsafe` in `chunks_fixed()`.
This is a step towards eliminating the `unsafe` code in `ChunksFixed`.
424b516
to
6e6b118
Compare
define_chunks_fixed!(12, 4); | ||
define_chunks_fixed!(16, 4); | ||
define_chunks_fixed!(16, 8); | ||
define_chunks_fixed!(32, 4); |
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.
For the small arrays that are converted here (the ones for which lines are removed above) this approach seems to optimize well. For the other two larger array sizes (mentioned below), I will post a separate PR that uses different techniques.
This change ends up being +91 −33 (+58 net) LoC. The future changes to eliminate I believe all the changes here don't worsen the code, and slightly improve the callers. The remaining changes to remove |
Replace a few uses of
ChunksFixed
with a newArraySplitMap
.ArraySplitMap
avoids the need to construct an intermediate array; we would hope the optimizer would handle that, but at least in the past it did not always do so.The approach here isn't very scalable since the source code of each implementation of
ArraySplitMap
grows twice as fast as the size of the input array. Maybe we can find a cleverer solution, at least for the larger ones.