-
-
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
Replace FloatOrd
with ordered_float
crate
#6917
Conversation
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
FloatOrd
type is only available forf32
, in some cases it is helpful to have af64
ordered float.Solution
I replaced
FloatOrd
inbevy_utils
iwthOrderedFloat<T>
from theordered_float
crate, which is generic and can be used withf32
andf64
. 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