]> granicus.if.org Git - graphviz/commitdiff
replace an open coded hypotenuse calculation in RAD with call to hypot
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 18 Jun 2021 00:31:55 +0000 (17:31 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Jun 2021 20:28:10 +0000 (13:28 -0700)
The libc function hypot does the same work, with the potential to be more
accurate and efficient.

lib/fdpgen/xlayout.c

index 975e4870f231f603f7fb46635c224555d918f156..03560fc25cb8d9ff73ca638b775117ea4d8a62c1 100644 (file)
@@ -28,6 +28,7 @@ Increase less between tries
 #include <neatogen/adjust.h>
 #include <fdpgen/dbg.h>
 #include <ctype.h>
+#include <math.h>
 
 /* Use bbox based force function */
 /* #define MS */
@@ -64,7 +65,7 @@ static double RAD(Agnode_t * n)
 {
     double w = WD2(n);
     double h = HT2(n);
-    return sqrt(w * w + h * h);
+    return hypot(w, h);
 }
 
 /* xinit_params: