From 37274b060d65c98dde8866f3d2c97dd3dd5333e2 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 19 Nov 2022 16:07:38 -0800 Subject: [PATCH] neatogen chkBoundBox: use a clearer iteration idiom --- lib/neatogen/adjust.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/neatogen/adjust.c b/lib/neatogen/adjust.c index e8d2d3d52..d5eae6376 100644 --- a/lib/neatogen/adjust.c +++ b/lib/neatogen/adjust.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -94,19 +95,16 @@ static void chkBoundBox(Agraph_t * graph) { Point ll, ur; - Info_t *ip = nodeInfo; - Poly *pp = &ip->poly; - double x = ip->site.coord.x; - double y = ip->site.coord.y; - double x_min = pp->origin.x + x; - double y_min = pp->origin.y + y; - double x_max = pp->corner.x + x; - double y_max = pp->corner.y + y; - for (size_t i = 1; i < nsites; i++) { - ip++; - pp = &ip->poly; - x = ip->site.coord.x; - y = ip->site.coord.y; + double x_min = DBL_MAX; + double y_min = DBL_MAX; + double x_max = -DBL_MAX; + double y_max = -DBL_MAX; + assert(nsites > 0); + for (size_t i = 0; i < nsites; ++i) { + Info_t *ip = &nodeInfo[i]; + Poly *pp = &ip->poly; + double x = ip->site.coord.x; + double y = ip->site.coord.y; x_min = fmin(x_min, pp->origin.x + x); y_min = fmin(y_min, pp->origin.y + y); x_max = fmax(x_max, pp->corner.x + x); -- 2.40.0