ref: 61fc64623183c2b3d79be27c857c6e44d8e6fc8d
parent: d8e71f6830473102b4a99ea1b9f89381dd989389
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Apr 13 11:58:44 EDT 2017
dict: overriding values
--- a/dict.c
+++ b/dict.c
@@ -67,12 +67,12 @@
/* return the index of key in d */
int dict_idx(struct dict *d, char *key)
{
- int *r = iset_get(d->map, DHASH(d, key));
- while (r && *r >= 0) {
+ int h = DHASH(d, key);
+ int *b = iset_get(d->map, h);
+ int *r = b + iset_len(d->map, h);
+ while (b && --r >= b)
if (!strcmp(d->key[*r], key))
return *r;
- r++;
- }
return -1;
}