From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 304843858C78 for ; Tue, 10 Jan 2023 18:33:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 304843858C78 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-il1-x12c.google.com with SMTP id o13so6826797ilc.7 for ; Tue, 10 Jan 2023 10:33:53 -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=yDoG+hoZdmsgsavRXKiT0DPykIzUxIM/OrYARLnfAxs=; b=FdStyPWD1pVoa6Pfqu9LKmpawP4VODvo8JpVcGZ3aXBGEMq/TondvJWvKBJPwx2ooV LWr2OzyLrHsH+T5AVeVatSmmsWCJlqSerHrCeGxgO+SgJuWYPdbVriCAyPPSuQtLG/0o fAzB6hRBYr95B+b+xBh3yQUGqestzrCxnpybhlnKWEMjcVGag22WfFK8v6JG+simDeXm R8JffJVBKjfa8ZxWSL6/fEcA+Glm8AfktkwJaKFv/8hi5g4sgkicZmQf7jymerduSYjc A0+JErFIvMA6x4Z8GIA653n3N6/1sBrebxNaXSEFe6gWyS9h1zXKC5DknrJ99wG8u5G/ F6PQ== 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=yDoG+hoZdmsgsavRXKiT0DPykIzUxIM/OrYARLnfAxs=; b=FxfoxinFtwU5y9clMoBkrAjqZicC8s0SlIirKrsTUuy8dOAwxMSuSrSQ3n9ebEQcTN 6mREm2RgGzYJBq6ntyA9yZ4eQH+ZBJIUBec96GaknBtSkpqTrfd6h4UIwB7A5MD/MgSb 1TYCUOftS13Ct407EFdT4nSqHo6/Tu/Tu295uI8aT9gLZZ+e77XGGD7OhgL1zpAk7HL+ dQ0EiVZ2PaiAfR3eHG1gYQujTOWjUnOQlhlhX++OdCLGB3RuT0vPv9dHtMlpFrDsBA2n wD7aT9Xkd64GHgpiaH7wXc1bOVYU7f2u5VzaMFwcu8rtj6ywGUQ9bG1IsuPdfbRyj6O/ 5o/Q== X-Gm-Message-State: AFqh2kqCGoNBVZKONLZu6RRQz0WEG2uiMD9wdHS29QYCZSvldbiXeZ/K +aY3l5A2ImCjlRXkisQr8moKrDuQl75wDpW0 X-Google-Smtp-Source: AMrXdXtz8jvGjW+U6A8iw8cERQgZlABkODkzIqBQlLo9Ba9W4wsbmgmmznVUqtNe0p0wXbi05dyHaw== X-Received: by 2002:a92:6e04:0:b0:302:b56c:63f6 with SMTP id j4-20020a926e04000000b00302b56c63f6mr48095982ilc.15.1673375631564; Tue, 10 Jan 2023 10:33:51 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id w20-20020a05663800d400b00375783003fcsm3739933jao.136.2023.01.10.10.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 10:33:51 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 3/4] Move hash_entry and eq_entry into cooked_index::do_finalize Date: Tue, 10 Jan 2023 11:33:37 -0700 Message-Id: <20230110183338.2623088-4-tromey@adacore.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230110183338.2623088-1-tromey@adacore.com> References: <20230110183338.2623088-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 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 93ffd923c76..c711e3b9b2a 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.38.1