Merged
Conversation
Closed
tarcieri
reviewed
Dec 21, 2023
src/uint/boxed/encoding.rs
Outdated
Comment on lines
165
to
169
| if err == 0 { | ||
| CtOption::new(Self { limbs: res.into() }, Choice::from(1)) | ||
| } else { | ||
| CtOption::new(Self::zero_with_precision(bits_precision), Choice::from(0)) | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| if err == 0 { | |
| CtOption::new(Self { limbs: res.into() }, Choice::from(1)) | |
| } else { | |
| CtOption::new(Self::zero_with_precision(bits_precision), Choice::from(0)) | |
| } | |
| CtOption::new(Self { limbs: res.into() }, Choice::from((err == 0) as u8) |
There may be a better way to construct the Choice, though I don't remember the possible values of err offhand
tarcieri
reviewed
Dec 21, 2023
Comment on lines
+99
to
+102
| // TODO: why not just !self.is_zero()? | ||
| self.limbs | ||
| .iter() | ||
| .fold(Choice::from(0), |acc, limb| acc | limb.is_nonzero().into()) |
tarcieri
reviewed
Dec 21, 2023
Comment on lines
+19
to
+20
| // TODO: investigate if directly comparing limbs is faster than performing a | ||
| // subtraction between limbs |
Member
There was a problem hiding this comment.
It could short-circuit, so that's definitely a yes
tarcieri
approved these changes
Dec 21, 2023
Member
tarcieri
left a comment
There was a problem hiding this comment.
This is fine aside from addressing some inline TODOs.
There are various allocations that could be optimized away in the boxed implementations but we can do that as a followup.
Member
|
I'm going to go ahead and land this since it's been so long in the tooth. @xuganyu96 if you'd like to open some followups for those TODOs or optimizations, that'd be great. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a another continuation of #436 after I lost track of where I overrode the master branch's changes.