Skip to content
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

fix: use total_cmp where possible #204

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Linear {
let (Ok(index) | Err(index)) =
self.stops.binary_search_by(|stop| match stop {
None => Ordering::Greater,
Some(stop) => stop.offset.partial_cmp(&offset).unwrap(),
Some(stop) => stop.offset.total_cmp(&offset),
});

if index < 8 {
Expand Down
3 changes: 1 addition & 2 deletions graphics/src/damage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@
/// Groups the given damage regions that are close together inside the given
/// bounds.
pub fn group(mut damage: Vec<Rectangle>, bounds: Rectangle) -> Vec<Rectangle> {
use std::cmp::Ordering;

Check warning on line 48 in graphics/src/damage.rs

View workflow job for this annotation

GitHub Actions / widget

unused import: `std::cmp::Ordering`

Check warning on line 48 in graphics/src/damage.rs

View workflow job for this annotation

GitHub Actions / web

unused import: `std::cmp::Ordering`

Check warning on line 48 in graphics/src/damage.rs

View workflow job for this annotation

GitHub Actions / wasm

unused import: `std::cmp::Ordering`

Check warning on line 48 in graphics/src/damage.rs

View workflow job for this annotation

GitHub Actions / wasm

unused import: `std::cmp::Ordering`

Check warning on line 48 in graphics/src/damage.rs

View workflow job for this annotation

GitHub Actions / widget

unused import: `std::cmp::Ordering`

Check warning on line 48 in graphics/src/damage.rs

View workflow job for this annotation

GitHub Actions / web

unused import: `std::cmp::Ordering`

Check warning on line 48 in graphics/src/damage.rs

View workflow job for this annotation

GitHub Actions / wasm

unused import: `std::cmp::Ordering`

Check warning on line 48 in graphics/src/damage.rs

View workflow job for this annotation

GitHub Actions / wasm

unused import: `std::cmp::Ordering`

const AREA_THRESHOLD: f32 = 20_000.0;

damage.sort_by(|a, b| {
a.center()
.distance(Point::ORIGIN)
.partial_cmp(&b.center().distance(Point::ORIGIN))
.unwrap_or(Ordering::Equal)
.total_cmp(&b.center().distance(Point::ORIGIN))
});

let mut output = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion graphics/src/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Linear {
let (Ok(index) | Err(index)) =
self.stops.binary_search_by(|stop| match stop {
None => Ordering::Greater,
Some(stop) => stop.offset.partial_cmp(&offset).unwrap(),
Some(stop) => stop.offset.total_cmp(&offset),
});

if index < 8 {
Expand Down
Loading