[PATCH spice-gtk] main: Avoid sqrt in monitor compare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



qsort cares about the sign of the difference and that should stay
the same
---
 src/channel-main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/channel-main.c b/src/channel-main.c
index cd3dee7..50c29f2 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -17,7 +17,6 @@
 */
 #include "config.h"
 
-#include <math.h>
 #include <spice/vd_agent.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
@@ -1029,8 +1028,8 @@ static int monitors_cmp(const void *p1, const void *p2, gpointer user_data)
 {
     const VDAgentMonConfig *m1 = p1;
     const VDAgentMonConfig *m2 = p2;
-    double d1 = sqrt(m1->x * m1->x + m1->y * m1->y);
-    double d2 = sqrt(m2->x * m2->x + m2->y * m2->y);
+    double d1 = m1->x * m1->x + m1->y * m1->y;
+    double d2 = m2->x * m2->x + m2->y * m2->y;
     int diff = d1 - d2;
 
     return diff == 0 ? (char*)p1 - (char*)p2 : diff;
-- 
2.11.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]