From c771aa205a62241ab4dbd52fd3c331feeb395566 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 19 Sep 2021 15:35:37 -0700 Subject: [PATCH] tclpathplan gt: rephrase into something more obvious 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 | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tclpkg/tclpathplan/find_ints.c b/tclpkg/tclpathplan/find_ints.c index d8155e498..60c44296a 100644 --- a/tclpkg/tclpathplan/find_ints.c +++ b/tclpkg/tclpathplan/find_ints.c @@ -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; } -- 2.40.0