Migrated to f32::total_cmp() function in FloatOrd::cmp()#5208
Migrated to f32::total_cmp() function in FloatOrd::cmp()#5208nhunds wants to merge 3 commits intobevyengine:mainfrom
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. |
james7132
left a comment
There was a problem hiding this comment.
Going to second the PartialOrd implementation. The Ord documentation explicitly states the two must be in sync.
There was a problem hiding this comment.
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