]> granicus.if.org Git - graphviz/commitdiff
tclpathplan gt: rephrase into something more obvious
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 19 Sep 2021 22:35:37 +0000 (15:35 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 25 Sep 2021 17:22:21 +0000 (10:22 -0700)
Similar to commit 1cf8e0225a6a215c93437a9972497f1cae0ffc8c. This is intended to
preserve the same semantics. It not only avoids two -Wfloat-equal warnings, but
makes this code so close to the leading comment that the comment can simply be
removed now.

tclpkg/tclpathplan/find_ints.c

index d8155e498c420a9d65c7a0d6d96f9202c7e78df4..60c44296ae51b4f6a30b8e21fcbde5c4245b37b5 100644 (file)
@@ -102,15 +102,20 @@ void find_ints(struct vertex vertex_list[],
     free(pvertex);
 }
 
-static int gt(const void *a, const void *b)
-{                              /* i > j if i.x > j.x or i.x = j.x and i.y > j.y  */
+static int gt(const void *a, const void *b) {
     const struct vertex *const *i = a;
     const struct vertex *const *j = b;
-    double t;
-    if ((t = (*i)->pos.x - (*j)->pos.x) != 0.)
-       return ((t > 0.) ? 1 : -1);
-    if ((t = (*i)->pos.y - (*j)->pos.y) == 0.)
-       return (0);
-    else
-       return ((t > 0.) ? 1 : -1);
+    if ((*i)->pos.x > (*j)->pos.x) {
+      return 1;
+    }
+    if ((*i)->pos.x < (*j)->pos.x) {
+      return -1;
+    }
+    if ((*i)->pos.y > (*j)->pos.y) {
+      return 1;
+    }
+    if ((*i)->pos.y < (*j)->pos.y) {
+      return -1;
+    }
+    return 0;
 }