From d3845eb93ef015f71c46cb21c36a750561bbd0c6 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 25 Jun 2021 19:45:08 -0700 Subject: [PATCH] rephrase open coded fmax/fmin in checkpath --- lib/common/routespl.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/common/routespl.c b/lib/common/routespl.c index 4faac103e..becd347ab 100644 --- a/lib/common/routespl.c +++ b/lib/common/routespl.c @@ -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; } -- 2.49.0