]> granicus.if.org Git - graphviz/commitdiff
replace hypotenuse calculation in computeoffset_qr with a call to hypot
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 5 May 2021 03:45:22 +0000 (20:45 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 12 May 2021 01:46:36 +0000 (18:46 -0700)
The function hypot is available in C99 and has the potential to compute the same
operation more efficiently and with greater precision.

lib/common/emit.c

index ae23ba53314f8a409dea849a512d0c0f1980e3be..0d799e44982fb7a2a71560b5216c4856fb7be5eb 100644 (file)
@@ -17,6 +17,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <locale.h>
+#include <math.h>
 #include <common/render.h>
 #include <cgraph/agxbuf.h>
 #include <common/htmltable.h>
@@ -1996,7 +1997,7 @@ static pointf computeoffset_qr(pointf p, pointf q, pointf r, pointf s,
     double len;
     double x = q.x - r.x, y = q.y - r.y;
 
-    len = sqrt(x * x + y * y);
+    len = hypot(x, y);
     if (len < EPSILON) {
        /* control points are on top of each other
           use slope between endpoints instead */