diff options
Diffstat (limited to 'src/njs_flathsh.h')
-rw-r--r-- | src/njs_flathsh.h | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/njs_flathsh.h b/src/njs_flathsh.h index 985bdab1..06fd00c0 100644 --- a/src/njs_flathsh.h +++ b/src/njs_flathsh.h @@ -13,9 +13,18 @@ typedef struct { typedef struct { - uint32_t next_elt; + /* next_elt + property descriptor : 32 bits */ + + uint32_t next_elt:26; + + uint32_t type:3; + uint32_t writable:1; + uint32_t enumerable:1; + uint32_t configurable:1; + uint32_t key_hash; - void *value; + + void *value[16 / sizeof(void *)]; } njs_flathsh_elt_t; @@ -72,7 +81,7 @@ struct njs_flathsh_query_s { #define njs_hash_elts(h) \ - ((njs_flathsh_elt_t *) ((char *) (h) + 16 /* njs_flathsh_descr_t size */)) + ((njs_flathsh_elt_t *) ((char *) (h) + sizeof(njs_flathsh_descr_t))) /* @@ -91,14 +100,13 @@ NJS_EXPORT njs_int_t njs_flathsh_unique_find(const njs_flathsh_t *fh, njs_flathsh_query_t *fhq); /* - * njs_flathsh_insert() adds a hash element. If the element is already - * present in flathsh and the fhq->replace flag is zero, then fhq->value - * is updated with the old element and NJS_DECLINED is returned. - * If the element is already present in flathsh and the fhq->replace flag - * is non-zero, then the old element is replaced with the new element. - * fhq->value is updated with the old element, and NJS_OK is returned. + * njs_flathsh_insert() adds a hash element. If the element is already present + * in flathsh and the fhq->replace flag is zero, then NJS_DECLINED is returned. + * If the element is already present in flathsh and the fhq->replace flag is + * non-zero, then the old element is replaced with the new element and NJS_OK is + * returned. * If the element is not present in flathsh, then it is inserted and - * NJS_OK is returned. The fhq->value is not changed. + * NJS_OK is returned. * On memory allocation failure NJS_ERROR is returned. * * The required njs_flathsh_query_t fields: key_hash, key, proto, replace, @@ -175,7 +183,7 @@ typedef struct njs_flathsh_proto_s njs_lvlhsh_proto_t; #define njs_lvlhsh_delete(lh, lhq) njs_flathsh_delete(lh, lhq) #define njs_lvlhsh_each_init(lhe, _proto) njs_flathsh_each_init(lhe, _proto) -njs_inline void * +njs_inline njs_flathsh_elt_t * njs_lvlhsh_each(const njs_flathsh_t *lh, njs_flathsh_each_t *lhe) { njs_flathsh_elt_t *e; @@ -185,7 +193,7 @@ njs_lvlhsh_each(const njs_flathsh_t *lh, njs_flathsh_each_t *lhe) return NULL; } - return e->value; + return e; } |