-
Notifications
You must be signed in to change notification settings - Fork 373
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
feat(p/int256): Optimize int256
with two's complement implementation
#2846
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2846 +/- ##
==========================================
+ Coverage 63.37% 63.54% +0.16%
==========================================
Files 566 566
Lines 79490 79605 +115
==========================================
+ Hits 50374 50582 +208
+ Misses 25727 25636 -91
+ Partials 3389 3387 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
great stuff
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.
A few more comments, apologies
@@ -192,7 +195,9 @@ func TestSub(t *testing.T) { | |||
{"-1", "-1", "0"}, | |||
{"-115792089237316195423570985008687907853269984665640564039457584007913129639935", "-115792089237316195423570985008687907853269984665640564039457584007913129639935", "0"}, | |||
{"-115792089237316195423570985008687907853269984665640564039457584007913129639935", "0", "-115792089237316195423570985008687907853269984665640564039457584007913129639935"}, |
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.
I get why this test works, but it's weird. Can we change the test so that instead of parsing also the want
, we simply compare the string? So we verify if it's the "canonical" representation?
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.
This goes for other tests as well
// OBS, differs from original mempooler int256 | ||
// ToString returns the decimal representation of z. | ||
// ToString returns a string representation of z in base 10. | ||
// The string is prefixed with a minus sign if z is negative. | ||
func (z *Int) ToString() string { |
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.
Could this not just be String(), actually?
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 these tests in general, can we keep the string constants of very large numbers out?
Ideally, these should be through math/big
, so that can programmatically verify them, but it doesn't exist yet, so let's just have them as descriptive constants.
Description
This PR optimizes the implementation of
int256
type. Key changes include:Performance Result
Additional improvements:
This change is expected to improve performance for most int256 operations. However, please note the performance degradation in division operations.
See Also
#2750 (review)
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description