]> granicus.if.org Git - graphviz/commitdiff
ortho: remove 'INLINEPQ' guarded code
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 6 Sep 2022 00:53:12 +0000 (17:53 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 11 Sep 2022 16:29:44 +0000 (09:29 -0700)
Nothing in the build systems defines this. In a modern build environment, a
caller can achieve the effect this code path was providing by using the
compiler’s link-time optimization options.

lib/ortho/fPQ.h

index 47b8302f8f7412b2e99ae385879a521c4e11cd10..d659ac005dab7c76b8dcd288fa96070b86f7d331 100644 (file)
 #define E_WT(e) (e->weight)
 #define E_INCR(e) (e->incr)
 
-#ifdef INLINEPQ
-
-#include "assert.h"
-static snode**  pq;
-static int     PQcnt;
-static snode    guard;
-static int     PQsize;
-
-static void
-PQgen(int sz)
-{
-  if (!pq) {
-    pq = gv_calloc(sz + 1, sizeof(snode*));
-    pq[0] = &guard;
-    PQsize = sz;
-  }
-  PQcnt = 0;
-}
-
-static void
-PQfree()
-{
-  free (pq);
-  pq = NULL;
-  PQcnt = 0;
-}
-
-static void
-PQinit()
-{
-  PQcnt = 0;
-}
-
-static void
-PQcheck ()
-{
-  int i;
-  for (i = 1; i <= PQcnt; i++) {
-    if (N_IDX(pq[i]) != i) {
-      assert (0);
-    }
-  }
-}
-
-static void
-PQupheap(int k)
-{
-  snode* x;
-  x = pq[k];
-  int     v = x->n_val;
-  int     next = k/2;
-  snode*  n;
-  
-  while (N_VAL(n = pq[next]) < v) {
-    pq[k] = n;
-    N_IDX(n) = k;
-    k = next;
-    next /= 2;
-  }
-  pq[k] = x;
-  N_IDX(x) = k;
-}
-
-static int
-PQ_insert(snode* np)
-{
-  if (PQcnt == PQsize) {
-    agerr (AGERR, "Heap overflow\n");
-    return 1;
-  }
-  PQcnt++;
-  pq[PQcnt] = np;
-  PQupheap (PQcnt);
-  PQcheck();
-  return 0;
-}
-
-static void
-PQdownheap (int k)
-{
-  snode*    x = pq[k];
-  int      v = N_VAL(x);
-  int      lim = PQcnt/2;
-  snode*    n;
-  int      j;
-
-  while (k <= lim) {
-    j = k+k;
-    n = pq[j];
-    if (j < PQcnt) {
-      if (N_VAL(n) < N_VAL(pq[j+1])) {
-        j++;
-        n = pq[j];
-      }
-    }
-    if (v >= N_VAL(n)) break;
-    pq[k] = n;
-    N_IDX(n) = k;
-    k = j;
-  }
-  pq[k] = x;
-  N_IDX(x) = k;
-}
-
-static snode*
-PQremove ()
-{
-  snode* n;
-
-  if (PQcnt) {
-    n = pq[1];
-    pq[1] = pq[PQcnt];
-    PQcnt--;
-    if (PQcnt) PQdownheap (1);
-    PQcheck();
-    return n;
-  }
-  else return 0;
-}
-
-static void
-PQupdate (snode* n, int d)
-{
-  N_VAL(n) = d;
-  PQupheap (n->n_idx);
-  PQcheck();
-}
-
-static void
-PQprint ()
-{
-  int    i;
-  snode*  n;
-
-  fprintf (stderr, "Q: ");
-  for (i = 1; i <= PQcnt; i++) {
-    n = pq[i];
-    fprintf (stderr, "%s(%d:%d) ",  
-      n->index, N_IDX(n), N_VAL(n));
-  }
-  fprintf (stderr, "\n");
-}
-#else
-
 #ifndef FPQ_H
 #define FPQ_H
 
@@ -182,4 +37,3 @@ snode* PQremove (void);
 void PQupdate (snode* n, int d);
 void PQprint (void);
 #endif
-#endif