diff options
| author | Tyge Løvset <[email protected]> | 2020-03-19 11:27:31 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-03-19 11:27:31 +0100 |
| commit | 7eac0fe0322ca96a6b7b80681fe86807e76a3e75 (patch) | |
| tree | e85d28b56266f5cac1ab70ea42d4f35297e74815 | |
| parent | ffef6a1c3bb46256e40e5613653abf480e7ee73c (diff) | |
| download | STC-modified-7eac0fe0322ca96a6b7b80681fe86807e76a3e75.tar.gz STC-modified-7eac0fe0322ca96a6b7b80681fe86807e76a3e75.zip | |
Add files via upload
| -rw-r--r-- | c_lib/cmap.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/c_lib/cmap.h b/c_lib/cmap.h index 85b56f79..c18ed91a 100644 --- a/c_lib/cmap.h +++ b/c_lib/cmap.h @@ -33,11 +33,11 @@ // CMapEntry:
#define declare_CMapEntry(tag, Key, Value, valueDestroy, keyDestroy) \
struct CMapEntry_##tag { \
- uint16_t used; \
- uint16_t changed; \
- uint32_t hash; \
Key key; \
Value value; \
+ uint8_t changed; \
+ uint8_t used; \
+ uint16_t hash; \
}; \
\
static inline void cmapentry_##tag##_destroy(struct CMapEntry_##tag* e) { \
@@ -125,14 +125,14 @@ static inline void cmap_##tag##_setMaxLoadFactor(CMap_##tag* self, float fac) { } \
\
static inline size_t cmap_##tag##_bucket(CMap_##tag* self, KeyRaw rawKey, uint32_t* h) { \
- uint32_t hash = keyHashRaw(&rawKey, sizeof(KeyRaw)); \
+ uint32_t hash = keyHashRaw(&rawKey, sizeof(KeyRaw)), hx = hash & 0xffff; \
size_t cap = cvector_capacity(self->_table); \
size_t idx = c_reduce(hash, cap); \
CMapEntry_##tag* slot = self->_table.data; \
- while (slot[idx].used && (slot[idx].hash != hash || keyCompareRaw(keyGetRaw(slot[idx].key), rawKey) != 0)) { \
+ while (slot[idx].used && (slot[idx].hash != hx || keyCompareRaw(keyGetRaw(slot[idx].key), rawKey) != 0)) { \
if (++idx == cap) idx = 0; \
} \
- *h = hash; \
+ *h = hx; \
return idx; \
} \
\
|
