bevy/crates/bevy_animation/src
Vic b78efd339d
Simplify sort/max_by calls (#17048)
# Objective

Some sort calls and `Ord` impls are unnecessarily complex.

## Solution

Rewrite the "match on cmp, if equal do another cmp" as either a
comparison on tuples, or `Ordering::then_with`, depending on whether the
compare keys need construction.

`sort_by` -> `sort_by_key` when symmetrical. Do the same for
`min_by`/`max_by`.

Note that `total_cmp` can only work with `sort_by`, and not on tuples.

When sorting collected query results that contain
`Entity`/`MainEntity`/`RenderEntity` in their `QueryData`, with that
`Entity` in the sort key:
stable -> unstable sort (all queried entities are unique)

If key construction is not simple, switch to `sort_by_cached_key` when
possible.

Sorts that are only performed to discover the maximal element are
replaced by `max_by_key`.

Dedicated comparison functions and structs are removed where simple.

Derive `PartialOrd`/`Ord` when useful.

Misc. closure style inconsistencies.

## Testing
- Existing tests.
2024-12-30 22:59:36 +00:00
..
animatable.rs Simplify sort/max_by calls (#17048) 2024-12-30 22:59:36 +00:00
animation_curves.rs Move Name out of bevy_core (#16894) 2024-12-19 02:45:16 +00:00
gltf_curves.rs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
graph.rs Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
lib.rs Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
transition.rs aligning public apis of Time,Timer and Stopwatch (#15962) 2024-10-16 21:09:32 +00:00
util.rs Animatable trait for interpolation and blending (#4482) 2024-02-02 21:19:37 +00:00