From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by sourceware.org (Postfix) with ESMTPS id A38B73896C0D for ; Thu, 15 Dec 2022 19:08:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A38B73896C0D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd36.google.com with SMTP id p6so91894iod.13 for ; Thu, 15 Dec 2022 11:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aSgqGyGlNexTVzD80yEZhozEzp3jaH8IV0mWH5wuuXo=; b=iE/HxuRm16iLpq/DVWThCvwKuQrznwKOFwbUjDUH907UnzWGW7hsbqZ7Tlxn9q8+2s D7b2W6fEdv+SZyKO+Qs+2KXGNJp/DDvl1i22qWTfpgVZXLtCo+M64yS0Yz8soHjOt5lM u49iiAA4zYadPJLArEmJEOkxiPk4uXQRyMCnzoJs9q2x/ytbGXqI6/cNeK5yLo9IPSoL qwHTou3SXRpicqyvYB0D4v/4+ZBv4dLY0fzLmZT6MeLxaGUgatKchYDsLJVuTe81qUrM zqaoq5BRwPhM5Y0afTIVZYh5fAijeKjjTNerZrpiJseqQKq/072vlj0USrQXOQrLr6UI 3FyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aSgqGyGlNexTVzD80yEZhozEzp3jaH8IV0mWH5wuuXo=; b=stO3dZAj+drnKWNyaxTYdSskqPrRYdO8FWEEzQMsa1G+k7ntFSae6V4JZMjpf7+xEp Xsz7NTKVI9pyPOVNZr+zWc8SDbQ4pRsSX+5iSPA6NvF6Ub+vPmLJrgIMU3EQW5MFntWg qtMjn6Vbkz2/2mRu/ZHYiuRwjQALmJ+le3OEEUAqbaPWQzy2rb/kZaQ6XTPxFLmcWqA9 K8ro5E6fJS4KBAxi7CccH6OgVXgQlL1aPQqenE55Q9myKs3pRTPj6fylk3EuQfhXW1RI ThlYHb6DP5x9LaQS5Pj7QpHwVMNLqlA2S2teYydMhuTOw3BQ91NWBJPR3E0s7MLzaZmg seeg== X-Gm-Message-State: ANoB5pn+1nwW3hLYfaUbynTI6Id6FnUuUDtsTNsiuPdvnSVc02zY5+no Rl5uZCmjfISftAiEW/o049fveuHylfFZv3R6 X-Google-Smtp-Source: AA0mqf7UxKVrt2PHFiU38flfUAjhhH39x7KytmjnI878t9VhOPHAYBO6XMEDFNwMWhTu3tWW16kWSg== X-Received: by 2002:a5e:dc07:0:b0:6e4:720a:2391 with SMTP id b7-20020a5edc07000000b006e4720a2391mr4024138iok.2.1671131291869; Thu, 15 Dec 2022 11:08:11 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id y74-20020a6bc84d000000b006e0338b60a5sm1413962iof.22.2022.12.15.11.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:08:11 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/4] Move hash_entry and eq_entry into cooked_index::do_finalize Date: Thu, 15 Dec 2022 12:07:58 -0700 Message-Id: <20221215190759.2494095-4-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221215190759.2494095-1-tromey@adacore.com> References: <20221215190759.2494095-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- 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 0aa026c7779..f3688a351c9 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -26,26 +26,6 @@ #include "split-name.h" #include -/* 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.34.3