-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Use a distinct ToString
implementation for u128
and i128
#142294
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
base: master
Are you sure you want to change the base?
Use a distinct ToString
implementation for u128
and i128
#142294
Conversation
rustbot has assigned @workingjubilee. Use |
☔ The latest upstream changes (presumably #136594) made this pull request unmergeable. Please resolve the merge conflicts. |
b5b6654
to
53dc659
Compare
Fixed merge conflicts. |
ToString
implementation on u128
and i128
ToString
implementation for u128
and i128
Having done code review of things that use Rust's |
Noted, thanks for the title update then. :) |
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.
If you've tested locally, is there any measurable perf/size impact here?
library/core/src/fmt/num.rs
Outdated
// This is not a typo, we use the maximum number of digits of `u128`, hence why we use | ||
// `u128::MAX`. | ||
const MAX_DEC_N: usize = u128::MAX.ilog(10) as usize + 1; |
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.
Maybe pop this constant out so it can be reused between u128 and i128?
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.
Done.
53dc659
to
9b09948
Compare
@tgross35 I added the comparison in the first comment with the code I use to get the performance comparison. |
Part of #135543.
Follow-up of #136264.
When working on #142098, I realized that
i128
andu128
could also benefit from a distinctToString
implementation so here it.The last commit is just me realizing that I forgot to add the format tests for
usize
andisize
.Here is the bench comparison:
I used this code to test: