diff options
| author | 2023-07-03 16:41:51 +0200 | |
|---|---|---|
| committer | 2023-07-03 16:41:51 +0200 | |
| commit | 5b3c7d45bbaa4bb0fee61b89f4ecc5df4c4ffcd8 (patch) | |
| tree | 436cecffbe17a2edaaa66ba83850658e92291217 /xs_set.h | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | penes-snac2-5b3c7d45bbaa4bb0fee61b89f4ecc5df4c4ffcd8.tar.gz penes-snac2-5b3c7d45bbaa4bb0fee61b89f4ecc5df4c4ffcd8.tar.xz penes-snac2-5b3c7d45bbaa4bb0fee61b89f4ecc5df4c4ffcd8.zip | |
Backport from xs.
Diffstat (limited to 'xs_set.h')
| -rw-r--r-- | xs_set.h | 16 |
1 files changed, 1 insertions, 15 deletions
| @@ -51,26 +51,12 @@ void xs_set_free(xs_set *s) | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | static unsigned int _calc_hash(const char *data, int size) | ||
| 55 | { | ||
| 56 | unsigned int hash = 0x666; | ||
| 57 | int n; | ||
| 58 | |||
| 59 | for (n = 0; n < size; n++) { | ||
| 60 | hash ^= data[n]; | ||
| 61 | hash *= 111111111; | ||
| 62 | } | ||
| 63 | |||
| 64 | return hash ^ hash >> 16; | ||
| 65 | } | ||
| 66 | |||
| 67 | |||
| 68 | static int _store_hash(xs_set *s, const char *data, int value) | 54 | static int _store_hash(xs_set *s, const char *data, int value) |
| 69 | { | 55 | { |
| 70 | unsigned int hash, i; | 56 | unsigned int hash, i; |
| 71 | int sz = xs_size(data); | 57 | int sz = xs_size(data); |
| 72 | 58 | ||
| 73 | hash = _calc_hash(data, sz); | 59 | hash = xs_hash_func(data, sz); |
| 74 | 60 | ||
| 75 | while (s->hash[(i = hash % s->elems)]) { | 61 | while (s->hash[(i = hash % s->elems)]) { |
| 76 | /* get the pointer to the stored data */ | 62 | /* get the pointer to the stored data */ |