-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Migrated to f32::total_cmp() function in FloatOrd::cmp() #5208
Conversation
Code change looks good to me. @DJMcNab, advice on the hash concern you raised? |
This should be benchmarked too 👍 |
I don't think the hash concern is relevant here, since the only thing that matters is hash in relation to PartialEq However, I think the clippy lint we ignore is making a good point - we should also implement PartialOrd in terms of this Ord impl. |
Saying that, I'm not convinced PartialEq doesn't have requirements related to the PartialOrd implementation Basically, we need to check the documentation for all four traits, which I can't right at this moment. |
I think we don't need the PartialEq implementation, but in my opinion it seems like f32 doesn't have a implementation of the Hash trait. |
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.
Going to second the PartialOrd
implementation. The Ord
documentation explicitly states the two must be in sync.
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.
We still need to think about the Hash
implementation
At the moment, we either:
- need a test which loops through all f32 values, and checks that the implementations agree. I expect that they won't, unfortunately.
- convert the only usage of this impl (in
FontAtlasSet
) to useBTreeMap
. I suspect for this workload, that would even be faster. This is the path I'd recommend taking
We also need to use a manual PartialOrd
impl.
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
Why would |
Based on the using Additionally, the keys are small, so a binary search should be very fast. |
The same approach taken in #10558 should be used here |
I'm going to close this out. Looks like this is wanted, but work has stalled out and the approach needs to be changed. Feel free to re-open. |
Objective
Fixes #5152
Solution
Use total_cmp() function from f32 in cmp() function on FloatOrd