summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-07-31 16:11:54 +0200
committerTyge Løvset <[email protected]>2022-07-31 16:14:38 +0200
commit8884747775e922e20b0646eeb29ce8a2b4a1c7cc (patch)
treec2b5aad085198dec951f67ecb1629a4d61a7b0f8
parentbc3f6613ba44adcecacbdd106c840e8b6c054e22 (diff)
downloadSTC-modified-8884747775e922e20b0646eeb29ce8a2b4a1c7cc.tar.gz
STC-modified-8884747775e922e20b0646eeb29ce8a2b4a1c7cc.zip
Changed cmap struct internal rep. so that load-factor is first: useful for global initialization of maps. This changes ABI, but so far STC has no stable ABI guarantees.
-rw-r--r--include/stc/cmap.h4
-rw-r--r--include/stc/forward.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 50df1b64..1cb8bb3f 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -53,7 +53,7 @@ int main(void) {
#include "forward.h"
#include <stdlib.h>
#include <string.h>
-#define _cmap_inits {NULL, NULL, 0, 0, 0.85f}
+#define _cmap_inits {0.85f}
typedef struct { size_t idx; uint8_t hx; } chash_bucket_t;
#endif // CMAP_H_INCLUDED
@@ -382,10 +382,10 @@ _cx_memb(_reserve)(_cx_self* self, const size_t _newcap) {
_nbuckets |= 1;
#endif
_cx_self m = {
+ self->max_load_factor,
c_alloc_n(_cx_value, _nbuckets),
(uint8_t *) c_calloc(_nbuckets + 1, 1),
self->size, (i_size)_nbuckets,
- self->max_load_factor
};
bool ok = m.table && m._hashx;
if (ok) { /* Rehash: */
diff --git a/include/stc/forward.h b/include/stc/forward.h
index 9c462b8e..04566b98 100644
--- a/include/stc/forward.h
+++ b/include/stc/forward.h
@@ -125,10 +125,10 @@ typedef union {
} SELF##_iter; \
\
typedef struct { \
+ float max_load_factor; \
SELF##_value* table; \
uint8_t* _hashx; \
SELF##_size_t size, bucket_count; \
- float max_load_factor; \
} SELF
#if defined STC_CSMAP_V1