]> granicus.if.org Git - graphviz/commitdiff
rephrase open coded fmax/fmin in checkpath
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 26 Jun 2021 02:45:08 +0000 (19:45 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 30 Jun 2021 02:32:59 +0000 (19:32 -0700)
lib/common/routespl.c

index 4faac103ec7dc4522a2f22213eb7f0e12d7ab04e..becd347ab9704a2c09f7daca1b297769b53e110b 100644 (file)
@@ -767,14 +767,10 @@ static int checkpath(int boxn, boxf* boxes, path* thepath)
            fprintf(stderr, "in checkpath, start port not in first box\n");
            printpath(thepath);
        }
-       if (thepath->start.p.x < boxes[0].LL.x)
-           thepath->start.p.x = boxes[0].LL.x;
-       if (thepath->start.p.x > boxes[0].UR.x)
-           thepath->start.p.x = boxes[0].UR.x;
-       if (thepath->start.p.y < boxes[0].LL.y)
-           thepath->start.p.y = boxes[0].LL.y;
-       if (thepath->start.p.y > boxes[0].UR.y)
-           thepath->start.p.y = boxes[0].UR.y;
+       thepath->start.p.x = fmax(thepath->start.p.x, boxes[0].LL.x);
+       thepath->start.p.x = fmin(thepath->start.p.x, boxes[0].UR.x);
+       thepath->start.p.y = fmax(thepath->start.p.y, boxes[0].LL.y);
+       thepath->start.p.y = fmin(thepath->start.p.y, boxes[0].UR.y);
     }
     if (thepath->end.p.x < boxes[boxn - 1].LL.x
        || thepath->end.p.x > boxes[boxn - 1].UR.x
@@ -784,14 +780,10 @@ static int checkpath(int boxn, boxf* boxes, path* thepath)
            fprintf(stderr, "in checkpath, end port not in last box\n");
            printpath(thepath);
        }
-       if (thepath->end.p.x < boxes[boxn - 1].LL.x)
-           thepath->end.p.x = boxes[boxn - 1].LL.x;
-       if (thepath->end.p.x > boxes[boxn - 1].UR.x)
-           thepath->end.p.x = boxes[boxn - 1].UR.x;
-       if (thepath->end.p.y < boxes[boxn - 1].LL.y)
-           thepath->end.p.y = boxes[boxn - 1].LL.y;
-       if (thepath->end.p.y > boxes[boxn - 1].UR.y)
-           thepath->end.p.y = boxes[boxn - 1].UR.y;
+       thepath->end.p.x = fmax(thepath->end.p.x, boxes[boxn - 1].LL.x);
+       thepath->end.p.x = fmin(thepath->end.p.x, boxes[boxn - 1].UR.x);
+       thepath->end.p.y = fmax(thepath->end.p.y, boxes[boxn - 1].LL.y);
+       thepath->end.p.y = fmin(thepath->end.p.y, boxes[boxn - 1].UR.y);
     }
     return 0;
 }