On 7/31/20 11:23 AM, [email protected] wrote:
> From: Anton Ivanov <[email protected]>
> 
> Add missing hash uses into shash to avoid hash recomputations.
> 
> Signed-off-by: Anton Ivanov <[email protected]>
> ---
>  lib/shash.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/shash.c b/lib/shash.c
> index 09505b73d..f378d1656 100644
> --- a/lib/shash.c
> +++ b/lib/shash.c
> @@ -158,8 +158,9 @@ shash_add(struct shash *sh, const char *name, const void 
> *data)
>  bool
>  shash_add_once(struct shash *sh, const char *name, const void *data)
>  {
> -    if (!shash_find(sh, name)) {
> -        shash_add(sh, name, data);
> +    size_t hash = hash_name(name);
> +    if (!shash_find__(sh, name, strlen(name), hash)) {
> +        shash_add_nocopy__(sh, xstrdup(name), data, hash);
>          return true;
>      } else {
>          return false;
> @@ -343,7 +344,7 @@ shash_equal_keys(const struct shash *a, const struct 
> shash *b)
>          return false;
>      }
>      SHASH_FOR_EACH (node, a) {
> -        if (!shash_find(b, node->name)) {
> +        if (!shash_find__(b, node->name, strlen(node->name), 
> node->node.hash)) {
>              return false;
>          }
>      }
> 

With the warning from 0-day robot above the line length addressed, this
patch looks good to me, thanks!

Acked-by: Dumitru Ceara <[email protected]>

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to