bevy/crates/bevy_winit/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
..
accessibility.rs Replace bevy_a11y::Focus with InputFocus (#16863) 2024-12-18 00:16:19 +00:00
converters.rs Expose text field from winit in KeyboardInput (#16864) 2024-12-17 22:42:54 +00:00
cursor.rs Rename trigger.entity() to trigger.target() (#16716) 2024-12-08 21:55:09 +00:00
lib.rs bevy_winit(emit raw winit events) (#15884) 2024-12-03 17:20:43 +00:00
state.rs bevy_winit(emit raw winit events) (#15884) 2024-12-03 17:20:43 +00:00
system.rs Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
winit_config.rs Reduce iOS cpu usage (#16548) 2024-11-29 00:34:40 +00:00
winit_monitors.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
winit_windows.rs Simplify sort/max_by calls (#17048) 2024-12-30 22:59:36 +00:00