diff options
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | ev.c | 9 |
2 files changed, 6 insertions, 4 deletions
@@ -1,5 +1,6 @@ Revision history for libev, a high-performance and full-featured event loop. +3.33 - use 1-based 2-heap for EV_MINIMAL, simplifies code, reduces codesize and makes for better cache-efficiency. - use 3-based 4-heap for !EV_MINIMAL. this makes better use @@ -770,7 +770,8 @@ fd_rearm_all (EV_P) #define USE_4HEAP !EV_MINIMAL #if USE_4HEAP -#define HEAP0 3 /* index of first element in heap */ +#define DHEAP 4 +#define HEAP0 (DHEAP - 1) /* index of first element in heap */ /* towards the root */ void inline_speed @@ -780,7 +781,7 @@ upheap (WT *heap, int k) for (;;) { - int p = ((k - HEAP0 - 1) / 4) + HEAP0; + int p = ((k - HEAP0 - 1) / DHEAP) + HEAP0; if (p >= HEAP0 || heap [p]->at <= w->at) break; @@ -805,10 +806,10 @@ downheap (WT *heap, int N, int k) { ev_tstamp minat; WT *minpos; - WT *pos = heap + 4 * (k - HEAP0) + HEAP0; + WT *pos = heap + DHEAP * (k - HEAP0) + HEAP0; // find minimum child - if (expect_true (pos +3 < E)) + if (expect_true (pos + DHEAP - 1 < E)) { /* fast path */ (minpos = pos + 0), (minat = (*minpos)->at); |