From: Matthew Fernandez Date: Sun, 20 Nov 2022 00:07:38 +0000 (-0800) Subject: neatogen chkBoundBox: use a clearer iteration idiom X-Git-Tag: 7.0.3~1^2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37274b060d65c98dde8866f3d2c97dd3dd5333e2;p=graphviz neatogen chkBoundBox: use a clearer iteration idiom --- 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);