From e3b087ac87a6b34ea1036e8ca072318f0b92be2d Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 28 Dec 2022 15:11:43 -0800 Subject: [PATCH] fdpgen: remove 'Wd2' parameter Without tracing the code, it was challenging to see that `Wd2` was always being set consistently to evaluate to `Wd * Wd`. We can remove this complexity by simply removing the parameter entirely and computing it on-demand. --- lib/fdpgen/tlayout.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/fdpgen/tlayout.c b/lib/fdpgen/tlayout.c index 30f9f3ffd..fd99f2d02 100644 --- a/lib/fdpgen/tlayout.c +++ b/lib/fdpgen/tlayout.c @@ -76,7 +76,6 @@ typedef struct { double K2; /* K*K */ double Wd; /* half-width of boundary */ double Ht; /* half-height of boundary */ - double Wd2; /* Wd*Wd */ double Ht2; /* Ht*Ht */ int pass1; /* iterations used in pass 1 */ int loopcnt; /* actual iterations in this pass */ @@ -99,7 +98,6 @@ static parms_t parms; #define T_K2 (parms.K2) #define T_Wd (parms.Wd) #define T_Ht (parms.Ht) -#define T_Wd2 (parms.Wd2) #define T_Ht2 (parms.Ht2) #define T_pass1 (parms.pass1) #define T_loopcnt (parms.loopcnt) @@ -371,7 +369,7 @@ static void updatePos(Agraph_t * g, double temp, bport_t * pp) /* if ports, limit by boundary */ if (pp) { - d = sqrt(x * x / T_Wd2 + y * y / T_Ht2); + d = sqrt(x * x / (T_Wd * T_Wd) + y * y / T_Ht2); if (IS_PORT(n)) { ND_pos(n)[0] = x / d; ND_pos(n)[1] = y / d; @@ -522,7 +520,6 @@ static pointf initPositions(graph_t * g, bport_t * pp) } else { ctr.x = ctr.y = 0; } - T_Wd2 = T_Wd * T_Wd; T_Ht2 = T_Ht * T_Ht; /* Set seed value */ -- 2.50.1