From 26b2c9c8d65ea4c54eebd4c7d48f7ee5fafa8866 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 25 Jun 2021 20:12:54 -0700 Subject: [PATCH] remove dead code in get_centroid The preceding return statement ensures none of the latter part of the function is reachable. This was introduced in 05674ae147c14ec4ec74b2b6771e04e0c82209b8 and seemingly never noticed. This commit also drops now-unused variables, as well as the static qualifier from sum. It is not clear to me what the purpose of making sum static was. It is a small struct and both its fields are overwritten immediately when entering this function, so there is no value to retaining it across calls or BSS-allocating it. --- lib/common/routespl.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/common/routespl.c b/lib/common/routespl.c index 3e9e8e1fa..eceb0052f 100644 --- a/lib/common/routespl.c +++ b/lib/common/routespl.c @@ -821,25 +821,11 @@ static void printpath(path * pp) static pointf get_centroid(Agraph_t *g) { - int cnt = 0; - static pointf sum = {0.0, 0.0}; - static Agraph_t *save; - Agnode_t *n; + pointf sum = {0.0, 0.0}; sum.x = (GD_bb(g).LL.x + GD_bb(g).UR.x) / 2.0; sum.y = (GD_bb(g).LL.y + GD_bb(g).UR.y) / 2.0; return sum; - - if (save == g) return sum; - save = g; - for (n = agfstnode(g); n; n = agnxtnode(g,n)) { - sum.x += ND_pos(n)[0]; - sum.y += ND_pos(n)[1]; - cnt++; - } - sum.x /= cnt; - sum.y /= cnt; - return sum; } //generic vector structure -- 2.40.0