core/place: Remove unnecessary sqrt in comparator functions

Remove unnecessary sqrt() calls in northwest_cmp and northeast_cmp.
The square root would have been necessary if we needed the actual distance,
but we only care about the relative order, so it isn't.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4202>
This commit is contained in:
Mattia Formichetti 2025-02-11 01:40:17 +01:00 committed by Marge Bot
parent 970ac8ff50
commit 14b90daa5a

View File

@ -72,9 +72,8 @@ northwest_cmp (gconstpointer a,
bx = b_frame.x;
by = b_frame.y;
/* probably there's a fast good-enough-guess we could use here. */
from_origin_a = (int) sqrt (ax * ax + ay * ay);
from_origin_b = (int) sqrt (bx * bx + by * by);
from_origin_a = ax * ax + ay * ay;
from_origin_b = bx * bx + by * by;
if (from_origin_a < from_origin_b)
return -1;
@ -105,9 +104,8 @@ northeast_cmp (gconstpointer a,
bx = (area->x + area->width) - (b_frame.x + b_frame.width);
by = b_frame.y;
/* probably there's a fast good-enough-guess we could use here. */
from_origin_a = (int) sqrt (ax * ax + ay * ay);
from_origin_b = (int) sqrt (bx * bx + by * by);
from_origin_a = ax * ax + ay * ay;
from_origin_b = bx * bx + by * by;
if (from_origin_a < from_origin_b)
return -1;