Commit 6904dca3 authored by Geoff Simmons's avatar Geoff Simmons

trackrdrd: hash_insert without goto

parent 365555a4
...@@ -499,37 +499,37 @@ static hashentry ...@@ -499,37 +499,37 @@ static hashentry
uint32_t h = h1(xid); uint32_t h = h1(xid);
he = &htbl.entry[INDEX(h)]; he = &htbl.entry[INDEX(h)];
if (he->state == HASH_EMPTY) if (he->state != HASH_EMPTY) {
goto ok; htbl.collisions++;
oldest = he;
htbl.collisions++;
oldest = he; h = h2(xid);
unsigned n = 0;
h = h2(xid); do {
unsigned n = 0; he = &htbl.entry[INDEX(h)];
do { probes++;
he = &htbl.entry[INDEX(h)];
probes++; if (he->state == HASH_EMPTY)
break;
if (he->state == HASH_EMPTY) if (he->insert_time < oldest->insert_time)
goto ok; oldest = he;
if (he->insert_time < oldest->insert_time) n++;
oldest = he; h += n * n;
n++; } while (probes <= htbl.max_probes);
h += n * n;
} while (probes <= htbl.max_probes); /* none eligible for evacuation */
if (he->state != HASH_EMPTY) {
if ((oldest->insert_time + htbl.mlt) > t) {
htbl.fail++;
htbl.insert_probes += probes;
return (NULL);
}
/* none eligible for evacuation */ hash_evacuate(oldest);
if ((oldest->insert_time + htbl.mlt) > t) { he = oldest;
htbl.fail++; }
htbl.insert_probes += probes;
return (NULL);
} }
hash_evacuate(oldest);
he = oldest;
ok:
htbl.insert_probes += probes; htbl.insert_probes += probes;
he->state = HASH_OPEN; he->state = HASH_OPEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment