From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 20B193858C2B; Tue, 17 Jan 2023 14:15:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20B193858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673964928; bh=HIqq9H3qEDYztWeXgabUQ4cSbA8coRL0T2RdAmA79wY=; h=From:To:Subject:Date:From; b=a9XRFVCbvP538MsCWMQtU9iH5Au76+/aIltcqYtEH/RpLa7lnP4m9hlvvyUAvc880 6wls+Lz4eZKbAT+D5fJPw6sPBarxFTSeMTMK3gKbKwVM6PvzSJ+EtoWwz8EcQShXgh tXbos8ehKrJWXXYA8bsqHpoN9sh7L+feLwmBs3Xs= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb/gdb-13-branch] Move hash_entry and eq_entry into cooked_index::do_finalize X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/gdb-13-branch X-Git-Oldrev: 6107546876df070688d75d8cd87d7c7a5f246091 X-Git-Newrev: 947b698401f036c8496663f063f7660a87472eb6 Message-Id: <20230117141528.20B193858C2B@sourceware.org> Date: Tue, 17 Jan 2023 14:15:28 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D947b698401f0= 36c8496663f063f7660a87472eb6 commit 947b698401f036c8496663f063f7660a87472eb6 Author: Tom Tromey Date: Thu Dec 15 09:38:05 2022 -0700 Move hash_entry and eq_entry into cooked_index::do_finalize =20 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. =20 (cherry picked from commit 5a89072f36ddd3be71103e3806d42ff5e49ff616) 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 =20 -/* Hash function for cooked_index_entry. */ - -static hashval_t -hash_entry (const void *e) -{ - const cooked_index_entry *entry =3D (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 =3D (const cooked_index_entry *) a; - const gdb::string_view *sv =3D (const gdb::string_view *) b; - return (strlen (ae->canonical) =3D=3D sv->length () - && strncasecmp (ae->canonical, sv->data (), sv->length ()) =3D=3D 0); -} - /* See cooked-index.h. */ =20 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)); =20 + auto hash_entry =3D [] (const void *e) + { + const cooked_index_entry *entry =3D (const cooked_index_entry *) e; + return dwarf5_djb_hash (entry->canonical); + }; + + auto eq_entry =3D [] (const void *a, const void *b) -> int + { + const cooked_index_entry *ae =3D (const cooked_index_entry *) a; + const gdb::string_view *sv =3D (const gdb::string_view *) b; + return (strlen (ae->canonical) =3D=3D sv->length () + && strncasecmp (ae->canonical, sv->data (), sv->length ()) =3D=3D 0= ); + }; + htab_up gnat_entries (htab_create_alloc (10, hash_entry, eq_entry, nullptr, xcalloc, xfree));