Replace FloatOrd with ordered_float crate#6917
Replace FloatOrd with ordered_float crate#6917BeastLe9enD wants to merge 1 commit intobevyengine:mainfrom ProjectKML:main
FloatOrd with ordered_float crate#6917Conversation
|
This changes the way NaN is handled from "sorting |
I am sure this won't be a problem in the code I changed, not sure if "sorting |
|
Last time we tried to change that trait this had unexpected performances impact. I can't find a comment on #5208 but I remember loss of performances when rendering. Could you get a tracy trace before and after on one of the examples with a lot of items to render (in the |
This might have changed after #5049, since we're now using radix sorts instead of |
|
I tested the version against the latest branch using the
|
|
Could you also try Try something like |
|
I tested the |
|
Thinking in terms of "is it worth it to add another dependency", I'm actually not sure:
Do you have a scenario currently where you are blocked of using ordered_float with |
|
Of course, I can understand what you mean. Bevy is not benefiting from it, at least at this point. F64 types are not used in Bevy. Since I use it myself, I just thought that it would be nice to use, since FloatOrd is also exported by bevy_utils. |
|
https://crates.io/crates/ordered-float shows it's a pretty commonly used crate so it likely wouldn't cause that big of a conflict, and it would make FloatOrd uses type-compatible with those external use cases. That said this code is pretty small and are definitely not on the bottleneck path for compilation. Overall, I would rather us just use something from the std/core lib for this if possible over an ecosystem crate. |
Objective
The
FloatOrdtype is only available forf32, in some cases it is helpful to have af64ordered float.Solution
I replaced
FloatOrdinbevy_utilsiwthOrderedFloat<T>from theordered_floatcrate, which is generic and can be used withf32andf64. I think it is okay to use an external crate for it, since it is already in version 3.0 and will not change anymore no unnecessary oter features :)Changelog
Migration Guide