]> granicus.if.org Git - graphviz/commitdiff
sparse QuadTree_get_nearest_internal: remove redundant branch
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 1 Jan 2023 21:43:33 +0000 (13:43 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 8 Jan 2023 19:06:28 +0000 (11:06 -0800)
lib/sparse/QuadTree.c

index d27722e39b7857e287a320ea7ecb7ed375dbc2a8..297354c026a141433dbb87532537395aca9a505a 100644 (file)
@@ -665,17 +665,15 @@ static void QuadTree_get_nearest_internal(QuadTree qt, double *x, double *y, dou
   if (!qt) return;
   dim = qt->dim;
   l = qt->l;
-  if (l){
-    while (l){
-      coord = node_data_get_coord(SingleLinkedList_get_data(l));
-      dist = point_distance(x, coord, dim);
-      if(*min < 0 || dist < *min) {
-       *min = dist;
-       *imin = node_data_get_id(SingleLinkedList_get_data(l));
-       for (i = 0; i < dim; i++) y[i] = coord[i];
-      }
-      l = SingleLinkedList_get_next(l);
+  while (l){
+    coord = node_data_get_coord(SingleLinkedList_get_data(l));
+    dist = point_distance(x, coord, dim);
+    if(*min < 0 || dist < *min) {
+      *min = dist;
+      *imin = node_data_get_id(SingleLinkedList_get_data(l));
+      for (i = 0; i < dim; i++) y[i] = coord[i];
     }
+    l = SingleLinkedList_get_next(l);
   }
   
   if (qt->qts){