-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
inline btoi to reduce compile times #1292
Conversation
Thanks a lot for your tremendous help with this! I will merge once CI is green after my refactor round. |
gix-utils/src/btoi.rs
Outdated
Ok(result) | ||
} | ||
|
||
/// minimal subset of traits used by btoi_radix and btou_radix |
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.
/// minimal subset of traits used by btoi_radix and btou_radix | |
/// minimal subset of traits used by [`to_signed_with_radix `] and [`to_signed_with_radix`] |
or however it is that doclinks (or just generally improve this doc?)
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.
That's a great catch, thanks for the suggestion.
I didn't apply the fix because it uses to_signed_with_radix
twice, but applied the intended fix locally and force-pushed.
/// | ||
fn zero() -> Self; |
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.
have you considered changing this to
/// | |
fn zero() -> Self; | |
/// the 0 value of this type | |
const ZERO: Self; |
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.
ahhh apologies for doing this post-merge, the browser hadn't refreshed
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.
Oh, I see! Some of these could probably be const, maybe const-fn in traits is allowed too?
In any case, if you would like to submit a PR, that would be very welcome.
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 just took this from num-traits with minor changes (changed &x parameters of checked_*
to pass by value cause its only used for small copy types here). Making it an associated const seems reasonable to me as well.
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 realized later in the evening that it was likely to do with MSRV that such consts were not used, but maybe that is 'too conservative'?
I'll see about a PR if that's ok with benmkw :)
This PR inlines the calls to btoi into gix-utils to reduce compile times (removes num-traits as well).
Compared to the previous diff I extracted basic tests from the doc comments and created a macro to make it easier to add new types/ reduce noise.
If needed I can squash the commits.
I have https://github.com/tamasfe/taplo installed and it reformatted the touched Cargo.toml files, I can revert that as well if wanted.
ref discussion in #729 (comment)