]> granicus.if.org Git - graphviz/commitdiff
smyrna scale_coords: remove open coded fmin/fmax
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 29 Sep 2021 00:24:20 +0000 (17:24 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 2 Oct 2021 00:00:18 +0000 (17:00 -0700)
cmd/smyrna/hier.c

index 8c9c9604b0e491adbf443fb066f243b098cbcaef..8354232a7559eab69b0b7c75ec00567d1b3d36b6 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "smyrnadefs.h"
 #include "hier.h"
+#include <math.h>
 #include <neatogen/delaunay.h>
 #include <common/memory.h>
 
@@ -31,14 +32,10 @@ scale_coords(double *x_coords, double *y_coords, int n,
     minX = maxX = x_coords[0];
     minY = maxY = y_coords[0];
     for (i = 1; i < n; i++) {
-       if (x_coords[i] < minX)
-           minX = x_coords[i];
-       if (y_coords[i] < minY)
-           minY = y_coords[i];
-       if (x_coords[i] > maxX)
-           maxX = x_coords[i];
-       if (y_coords[i] > maxY)
-           maxY = y_coords[i];
+       minX = fmin(minX, x_coords[i]);
+       minY = fmin(minY, y_coords[i]);
+       maxX = fmax(maxX, x_coords[i]);
+       maxY = fmax(maxY, y_coords[i]);
     }
     for (i = 0; i < n; i++) {
        x_coords[i] -= minX;