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.
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