fx.collections: hashtable: update allocate_index_for_key to handle exact key matches
This commit is contained in:
@@ -114,6 +114,15 @@ static fx_status allocate_index_for_key(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const struct fx_hashtable_item_p *item = fx_object_get_private(
|
||||||
|
table[index].i_item,
|
||||||
|
FX_TYPE_HASHTABLE_ITEM);
|
||||||
|
int cmp = fx_value_compare(&item->i_key, v);
|
||||||
|
if (cmp == 0) {
|
||||||
|
ok = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
index = (index + (i * i)) % table_size;
|
index = (index + (i * i)) % table_size;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -277,7 +286,6 @@ static fx_status hashtable_put(
|
|||||||
fx_value_copy(&item_p->i_key, key);
|
fx_value_copy(&item_p->i_key, key);
|
||||||
fx_value_copy(&item_p->i_value, value);
|
fx_value_copy(&item_p->i_value, value);
|
||||||
|
|
||||||
assert(hashtable->t_items[index].i_item == NULL);
|
|
||||||
hashtable->t_items[index].i_item = item;
|
hashtable->t_items[index].i_item = item;
|
||||||
hashtable->t_count++;
|
hashtable->t_count++;
|
||||||
return FX_SUCCESS;
|
return FX_SUCCESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user