From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 05AE03858D28; Tue, 17 Jan 2023 14:05:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05AE03858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673964354; bh=3BrMcSXsqhxIXWkukmdvvNxFk3zG/PHzuGw6ltBmBDc=; h=From:To:Subject:Date:From; b=Ob9MFBeBp0RZb45b2zv6M8C4rzKri0ZWwKihxcBg85jrKA8QpPqFTyZC0Vm8VRj8i yvA6ntwVxvGS4dcqi1n8gTlsZvF86Wz/3sbLQNIePThkzXytZ1FSckrRKBaexBorRn CUY8acjLQQIri7vrpeZW5kGZIC0nOn4m42KwIjNk= 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] 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/master X-Git-Oldrev: 1a6191f1a614f61d20bfe414b81c39a8ca785cc7 X-Git-Newrev: 5a89072f36ddd3be71103e3806d42ff5e49ff616 Message-Id: <20230117140554.05AE03858D28@sourceware.org> Date: Tue, 17 Jan 2023 14:05:54 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5a89072f36dd= d3be71103e3806d42ff5e49ff616 commit 5a89072f36ddd3be71103e3806d42ff5e49ff616 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. 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));