Created
August 26, 2011 14:21
-
-
Save delamonpansie/1173496 to your computer and use it in GitHub Desktop.
Am I crazy?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static uint32_t | |
_mh(put_slot_x)(struct _mh(t) *h, mh_key_t key) | |
{ | |
uint32_t inc, k, i, p = h->n_buckets, j = 0; | |
k = mh_hash(key); | |
i = k % h->n_buckets; | |
inc = 1 + k % (h->n_buckets - 1); | |
for (;;) { | |
if (mh_exist(h, i)) { | |
if (mh_eq(h->p[i].key, key)) | |
return i; | |
if (p == h->n_buckets) | |
mh_setdirty(h, i); | |
} else { | |
p = i; | |
goto fast_loop; | |
} | |
i += inc; | |
if (i >= h->n_buckets) | |
i -= h->n_buckets; | |
j++; | |
} | |
for (;;) { | |
if (mh_exist(h, i)) { | |
if (mh_eq(h->p[i].key, key)) | |
return i; | |
} else { | |
fast_loop: | |
if (!mh_dirty(h, i)) | |
return p; | |
} | |
i += inc; | |
if (i >= h->n_buckets) | |
i -= h->n_buckets; | |
j++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment