]> granicus.if.org Git - graphviz/commitdiff
common: replace some 'MAX' usage with 'fmax'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 9 Oct 2022 20:13:08 +0000 (13:13 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 11 Oct 2022 05:06:07 +0000 (22:06 -0700)
`fmax` is typically implemented as a compiler built-in and has the potential to
be more efficient than `MAX`, while also avoiding the loss of type safety and
double-expansion problems of macros.

lib/common/ellipse.c

index 79634fe1108e45bf179c9e40c51ea9c2876179e6..f7b9266ab82c80d281d957948b9ac44afaa0e36b 100644 (file)
  */
 
 #include <cgraph/alloc.h>
+#include <math.h>
 #include <stdbool.h>
 #ifdef STANDALONE
 #include <limits.h>
-#include <math.h>
 #include <stdlib.h>
 #include <stdio.h>
 
-#define MAX(a,b)        ((a)>(b)?(a):(b))
 #define MIN(a,b)        ((a)<(b)?(a):(b))
 
 typedef struct {
@@ -180,11 +179,11 @@ static void computeBounds(ellipse_t * ep)
     ep->width = ((etaXMax <= ep->eta2)
                 ? (ep->cx + ep->a * cos(etaXMax) * ep->cosTheta -
                    ep->b * sin(etaXMax) * ep->sinTheta)
-                : MAX(ep->x1, ep->x2)) - ep->xLeft;
+                : fmax(ep->x1, ep->x2)) - ep->xLeft;
     ep->height = ((etaYMax <= ep->eta2)
                  ? (ep->cy + ep->a * cos(etaYMax) * ep->sinTheta +
                     ep->b * sin(etaYMax) * ep->cosTheta)
-                 : MAX(ep->y1, ep->y2)) - ep->yUp;
+                 : fmax(ep->y1, ep->y2)) - ep->yUp;
 
 }