From f1a2706624de6613d8b1f08b320b34f4fe8b1bc9 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 5 May 2022 08:32:35 -0700 Subject: [PATCH] smyrna: simplify bounding box calculation in 'set_boundaries' --- cmd/smyrna/topviewfuncs.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/cmd/smyrna/topviewfuncs.c b/cmd/smyrna/topviewfuncs.c index e1b87bc44..15cd6e490 100644 --- a/cmd/smyrna/topviewfuncs.c +++ b/cmd/smyrna/topviewfuncs.c @@ -23,6 +23,7 @@ #include #include #include +#include static xdot *parseXdotwithattrs(void *e) { @@ -54,27 +55,15 @@ static void set_boundaries(Agraph_t * g) Agsym_t* pos_attr = GN_pos(g); glCompPoint pos; float left = FLT_MAX, right = -FLT_MAX, top = FLT_MAX, bottom = -FLT_MAX; - int id=0; for (v = agfstnode(g); v; v = agnxtnode(g, v)) { pos=getPointFromStr(agxget(v, pos_attr)); - if(id==0) - { - left=pos.x; - right=pos.x; - top=pos.y; - bottom=pos.y; - } - if (left > pos.x) - left = pos.x; - if (right < pos.x) - right = pos.x; - if (bottom > pos.y) - bottom = pos.y; - if (top < pos.y) - top = pos.y; - id++; + + left = fminf(left, pos.x); + right = fmaxf(right, pos.x); + top = fmaxf(top, pos.y); + bottom = fminf(bottom, pos.y); } view->bdxLeft = left; view->bdyTop = top; -- 2.40.0