summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2007-12-11 21:04:40 +0000
committerroot <root>2007-12-11 21:04:40 +0000
commit0e5eb45308c4238186cdad9a9d838dd04394e1bd (patch)
tree5648fe1c0b097d043b3f5312d867a170bc9c41ac
parent4ce77a5b1de05dae6092eae478b2a4397173d9c3 (diff)
*** empty log message ***rel-1_8
-rw-r--r--ev.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/ev.c b/ev.c
index acde504..371c62b 100644
--- a/ev.c
+++ b/ev.c
@@ -478,7 +478,7 @@ ev_feed_event (EV_P_ void *w, int revents)
}
}
-void inline_size
+void inline_speed
queue_events (EV_P_ W *events, int eventcnt, int type)
{
int i;
@@ -640,11 +640,16 @@ upheap (WT *heap, int k)
{
WT w = heap [k];
- while (k && heap [k >> 1]->at > w->at)
+ while (k)
{
- heap [k] = heap [k >> 1];
+ int p = (k - 1) >> 1;
+
+ if (heap [p]->at <= w->at)
+ break;
+
+ heap [k] = heap [p];
((W)heap [k])->active = k + 1;
- k >>= 1;
+ k = p;
}
heap [k] = w;
@@ -657,19 +662,23 @@ downheap (WT *heap, int N, int k)
{
WT w = heap [k];
- while (k < (N >> 1))
+ for (;;)
{
- int j = k << 1;
+ int c = (k << 1) + 1;
+
+ if (c >= N)
+ break;
- if (j + 1 < N && heap [j]->at > heap [j + 1]->at)
- ++j;
+ c += c + 1 < N && heap [c]->at > heap [c + 1]->at
+ ? 1 : 0;
- if (w->at <= heap [j]->at)
+ if (w->at <= heap [c]->at)
break;
- heap [k] = heap [j];
+ heap [k] = heap [c];
((W)heap [k])->active = k + 1;
- k = j;
+
+ k = c;
}
heap [k] = w;