From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 3084C3858C50 for ; Sat, 14 Jan 2023 06:06:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3084C3858C50 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-wr1-x42d.google.com with SMTP id v2so11837768wrw.10 for ; Fri, 13 Jan 2023 22:06:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Hl/TffhL8pi940oXvje1cHIzoE53jl/KuAdrSsRtHIc=; b=Zl87pPjh//RjyODTcs0K3XmAxiSnAP25nT670C77nXUNApd4nhMdSfoqxDyhddPCBo 8joLA5SMgUcHm3rys+ijL1btpaAPbr2PDhTOxMvsOT24ma/mnnmW+oRxLu//M1DMxkI+ Ti96TJwnXEvZlyrrXxyPPWvs9AcfRvqdnFa3qeQSdokLkPstsGtfsVmuftTahtiC4yaf 8zjcsO8/uc/zfM1CL4n3NM809QYj6LixhnCvOSych0BkIFxqYMJRBxOmolsXD9T3XDTP lLRa86DPyJ//Fy6PHgSj4svgcGPhjI7yI3zE/HSH6p3CB5EmuOm3BkXfhUei5ZcNNTGu Zaug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Hl/TffhL8pi940oXvje1cHIzoE53jl/KuAdrSsRtHIc=; b=wFeYqRZj5G2wwwTGUBpVr9Huda5MBaXHhzSYOdVhPSDb4DRXGavGEiFusSq8in49JG QOT72vNjdpEa75+ExV463bWxMTi7tIpY59jgRZOosEUVo+TzUFCWm/6cqE10ISlWRdsH YTBvnsnQ0vvRMHN5u6cJ2XbeVIOl/oQTsel6PlBg04mNQfyWqLEHRZSia7NS+wSqB2Nw taamjTR+g+v+p2VvQ6vsqaAeEVOEKr+ON+dRpxhhkumo+SD77vXxnIQuM3Q2vXKQaLsF G+0vokNsQ8KltkGSsbZnuDKfCYwROmwhnhrU2NxT0rUYbL2yFqB89y8GfTlHqULayXTa amCA== X-Gm-Message-State: AFqh2kpuvBjH21I/0FyHhwRnLQ0wDT0MTHlEDZKDcZ6kVdsbmB5XY+O4 2xg8NV2M4JK7dX4Yn0tjhUW+ X-Google-Smtp-Source: AMrXdXvGyeRxA2+qqjSVlDQT4N9/JhaiHwimLl1b/CgBTyWpXar3XcSlaQxLwyozTZkUosjIjwUIdg== X-Received: by 2002:adf:f24f:0:b0:2bb:b17e:789 with SMTP id b15-20020adff24f000000b002bbb17e0789mr16675484wrp.58.1673676377963; Fri, 13 Jan 2023 22:06:17 -0800 (PST) Received: from takamaka.gnat.com (lfbn-reu-1-488-54.w92-130.abo.wanadoo.fr. [92.130.77.54]) by smtp.gmail.com with ESMTPSA id bj7-20020a0560001e0700b002b6667d3adfsm20646221wrb.80.2023.01.13.22.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 22:06:17 -0800 (PST) Received: by takamaka.gnat.com (Postfix, from userid 1000) id A2DB68219E; Sat, 14 Jan 2023 10:06:15 +0400 (+04) Date: Sat, 14 Jan 2023 10:06:15 +0400 From: Joel Brobecker To: Tom Tromey via Gdb-patches Cc: Tom Tromey , Joel Brobecker Subject: Re: [PATCH v2 3/4] Move hash_entry and eq_entry into cooked_index::do_finalize Message-ID: References: <20230110183338.2623088-1-tromey@adacore.com> <20230110183338.2623088-4-tromey@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230110183338.2623088-4-tromey@adacore.com> X-Spam-Status: No, score=-10.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. Still OK for me :-). > 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 > -- Joel