mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
optimize the search of empty slot in the hashid_node array
This commit is contained in:
@@ -90,7 +90,7 @@ hashid_insert(struct hashid * hi, int id) {
|
|||||||
struct hashid_node *c = NULL;
|
struct hashid_node *c = NULL;
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<hi->cap;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) {
|
if (hi->id[index].id == -1) {
|
||||||
c = &hi->id[index];
|
c = &hi->id[index];
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user