public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Move hash_entry and eq_entry into cooked_index::do_finalize
Date: Tue, 17 Jan 2023 14:05:54 +0000 (GMT)	[thread overview]
Message-ID: <20230117140554.05AE03858D28@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5a89072f36ddd3be71103e3806d42ff5e49ff616

commit 5a89072f36ddd3be71103e3806d42ff5e49ff616
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Dec 15 09:38:05 2022 -0700

    Move hash_entry and eq_entry into cooked_index::do_finalize
    
    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.

Diff:
---
 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));

                 reply	other threads:[~2023-01-17 14:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230117140554.05AE03858D28@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /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).