Sort using more deterministic algorithm
`hypot` while useful for most of the cases, may break sorting assumptions like deterministic comparison. As seen in: https://github.com/pop-os/cosmic-launcher/issues/352 Add and use a new method that trades the performance for more determinism.
This commit is contained in:
parent
fc6b46342b
commit
044496f652
2 changed files with 14 additions and 2 deletions
|
|
@ -49,8 +49,8 @@ pub fn group(mut damage: Vec<Rectangle>, bounds: Rectangle) -> Vec<Rectangle> {
|
|||
|
||||
damage.sort_by(|a, b| {
|
||||
a.center()
|
||||
.distance(Point::ORIGIN)
|
||||
.total_cmp(&b.center().distance(Point::ORIGIN))
|
||||
.distance_slow(Point::ORIGIN)
|
||||
.total_cmp(&b.center().distance_slow(Point::ORIGIN))
|
||||
});
|
||||
|
||||
let mut output = Vec::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue