public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
Cc: Tom Tromey <tromey@adacore.com>, Joel Brobecker <brobecker@adacore.com>
Subject: Re: [PATCH v2 3/4] Move hash_entry and eq_entry into cooked_index::do_finalize
Date: Sat, 14 Jan 2023 10:06:15 +0400	[thread overview]
Message-ID: <Y8JGVzoRLkkDi0zx@adacore.com> (raw)
In-Reply-To: <20230110183338.2623088-4-tromey@adacore.com>

> I was briefly confused by the hash_entry and eq_entry functions in the
> cooked index.  They are only needed in a single method, and that
> method already has a couple of local lambdas for a different hash
> table.  So, it seemed cleaner to move these there as well.

Still OK for me :-).

>  gdb/dwarf2/cooked-index.c | 34 ++++++++++++++--------------------
>  1 file changed, 14 insertions(+), 20 deletions(-)
> 
> diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
> index 93ffd923c76..c711e3b9b2a 100644
> --- a/gdb/dwarf2/cooked-index.c
> +++ b/gdb/dwarf2/cooked-index.c
> @@ -26,26 +26,6 @@
>  #include "split-name.h"
>  #include <algorithm>
>  
> -/* Hash function for cooked_index_entry.  */
> -
> -static hashval_t
> -hash_entry (const void *e)
> -{
> -  const cooked_index_entry *entry = (const cooked_index_entry *) e;
> -  return dwarf5_djb_hash (entry->canonical);
> -}
> -
> -/* Equality function for cooked_index_entry.  */
> -
> -static int
> -eq_entry (const void *a, const void *b)
> -{
> -  const cooked_index_entry *ae = (const cooked_index_entry *) a;
> -  const gdb::string_view *sv = (const gdb::string_view *) b;
> -  return (strlen (ae->canonical) == sv->length ()
> -	  && strncasecmp (ae->canonical, sv->data (), sv->length ()) == 0);
> -}
> -
>  /* See cooked-index.h.  */
>  
>  const char *
> @@ -191,6 +171,20 @@ cooked_index::do_finalize ()
>    htab_up seen_names (htab_create_alloc (10, hash_name_ptr, eq_name_ptr,
>  					 nullptr, xcalloc, xfree));
>  
> +  auto hash_entry = [] (const void *e)
> +    {
> +      const cooked_index_entry *entry = (const cooked_index_entry *) e;
> +      return dwarf5_djb_hash (entry->canonical);
> +    };
> +
> +  auto eq_entry = [] (const void *a, const void *b) -> int
> +    {
> +      const cooked_index_entry *ae = (const cooked_index_entry *) a;
> +      const gdb::string_view *sv = (const gdb::string_view *) b;
> +      return (strlen (ae->canonical) == sv->length ()
> +	      && strncasecmp (ae->canonical, sv->data (), sv->length ()) == 0);
> +    };
> +
>    htab_up gnat_entries (htab_create_alloc (10, hash_entry, eq_entry,
>  					   nullptr, xcalloc, xfree));
>  
> -- 
> 2.38.1
> 

-- 
Joel

  reply	other threads:[~2023-01-14  6:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 18:33 [PATCH v2 0/4] Fix regression in new DWARF reader Tom Tromey
2023-01-10 18:33 ` [PATCH v2 1/4] Avoid submitting empty tasks in parallel_for_each Tom Tromey
2023-01-14  6:03   ` Joel Brobecker
2023-01-10 18:33 ` [PATCH v2 2/4] Don't erase empty indices in DWARF reader Tom Tromey
2023-01-14  6:05   ` Joel Brobecker
2023-01-17 13:53     ` Tom Tromey
2023-01-10 18:33 ` [PATCH v2 3/4] Move hash_entry and eq_entry into cooked_index::do_finalize Tom Tromey
2023-01-14  6:06   ` Joel Brobecker [this message]
2023-01-10 18:33 ` [PATCH v2 4/4] Fix parameter-less template regression in new DWARF reader Tom Tromey
2023-01-14  6:11   ` Joel Brobecker
2023-01-17 13:54     ` Tom Tromey
2023-01-17 16:44     ` Tom de Vries
2023-01-17 18:46       ` Tom Tromey
2023-01-17 18:09   ` Simon Marchi
2023-01-17 19:39     ` Tom Tromey
2023-01-27  5:47       ` Simon Marchi
2023-01-27 10:15         ` Andrew Burgess
2023-01-27 14:30           ` Tom Tromey
2023-01-27 19:57             ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y8JGVzoRLkkDi0zx@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).