bevy/crates/bevy_scene/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
..
bundle.rs Allow World::entity family of functions to take multiple entities and get multiple references back (#15614) 2024-10-07 15:21:40 +00:00
components.rs Add missing #[reflect(Component, Default)] to SceneRoot and DynamicSceneRoot. (#16816) 2024-12-15 19:18:22 +00:00
dynamic_scene_builder.rs bevy_scene: Use FromReflect on extracted resources (#15753) 2024-10-09 02:56:35 +00:00
dynamic_scene.rs Refactor hierarchy-related commands to remove structs (#17029) 2024-12-30 20:58:03 +00:00
lib.rs Migrate scenes to required components (#15579) 2024-10-01 22:42:11 +00:00
scene_filter.rs Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
scene_loader.rs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
scene_spawner.rs Refactor hierarchy-related commands to remove structs (#17029) 2024-12-30 20:58:03 +00:00
scene.rs Add scene summary (#15679) 2024-10-06 19:03:56 +00:00
serde.rs Simplify sort/max_by calls (#17048) 2024-12-30 22:59:36 +00:00