]> granicus.if.org Git - graphviz/commitdiff
fdpgen: remove 'Wd2' parameter
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 28 Dec 2022 23:11:43 +0000 (15:11 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 1 Jan 2023 00:38:35 +0000 (16:38 -0800)
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

index 30f9f3ffdfef0f6d9cee3ea9715c7451cb5cc38e..fd99f2d027c750d5f3572c22644f08cef73d7bbb 100644 (file)
@@ -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 */