optimize the search of empty slot in the hashid_node array

This commit is contained in:
Chen Puqing
2014-02-18 23:18:29 +08:00
parent ac6a140130
commit 224a1eebfb

View File

@@ -90,7 +90,7 @@ hashid_insert(struct hashid * hi, int id) {
struct hashid_node *c = NULL;
int i;
for (i=0;i<hi->cap;i++) {
int index = (i+hi->count) % hi->cap;
int index = (i+id) % hi->cap;
if (hi->id[index].id == -1) {
c = &hi->id[index];
break;