details: https://github.com/nginx/njs/commit/fee06cb2fe461a277b804f72bcef4f9ae89cafdd branches: master commit: fee06cb2fe461a277b804f72bcef4f9ae89cafdd user: Vadim Zhestikov <v.zhesti...@f5.com> date: Thu, 12 Jun 2025 08:34:17 -0700 description: Ignoring previous value in njs_flathsh_insert().
Previously, fhq->value was set to a previous value if the value existed. This is not used anymore in the code. --- src/njs_flathsh.c | 7 +------ src/njs_flathsh.h | 13 ++++++------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/njs_flathsh.c b/src/njs_flathsh.c index a9ef6e69..5a4efaa5 100644 --- a/src/njs_flathsh.c +++ b/src/njs_flathsh.c @@ -376,7 +376,6 @@ njs_flathsh_unique_find(const njs_flathsh_t *fh, njs_flathsh_query_t *fhq) njs_int_t njs_flathsh_insert(njs_flathsh_t *fh, njs_flathsh_query_t *fhq) { - void *tmp; njs_int_t cell_num, elt_num; njs_flathsh_elt_t *elt, *elts; njs_flathsh_descr_t *h; @@ -403,15 +402,11 @@ njs_flathsh_insert(njs_flathsh_t *fh, njs_flathsh_query_t *fhq) fhq->proto->test(fhq, elt->value) == NJS_OK) { if (fhq->replace) { - tmp = fhq->value; - fhq->value = elt->value; - elt->value = tmp; + elt->value = fhq->value; return NJS_OK; } else { - fhq->value = elt->value; - return NJS_DECLINED; } } diff --git a/src/njs_flathsh.h b/src/njs_flathsh.h index 985bdab1..e15162d6 100644 --- a/src/njs_flathsh.h +++ b/src/njs_flathsh.h @@ -91,14 +91,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, _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org https://mailman.nginx.org/mailman/listinfo/nginx-devel