From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id A7D793858D35 for ; Sat, 7 Jan 2023 11:26:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7D793858D35 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-wm1-x32b.google.com with SMTP id m3so2739463wmq.0 for ; Sat, 07 Jan 2023 03:26:58 -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=BdoDM6Fcp+zj8x+ZW8NaeyYQ3wgTOS6KSHp3tHo000o=; b=lSslOMOo8PovgxaNQjJBY1+lT8te3WiHcB5UrKO1foFVQDuODJOVyfV0bxjbhLuyz6 COJHo2m2hM4h02AtfLsLWo5F3BOlAOYH/eSeGhVELGwb9DuSCH3+peqOdy6PXv357hyj LpxAjr32Pu7924tfT3sIvEI376hrAY+QXkEru9djGPWwNmQvwcm/OeNUO83GOgMB6ZZ2 aHqiW/nZU5oybAg9JeXW03X8JEd5ZJspUo5nSf6oiVxCtNEKSDe5uNFBc+wUsgCGu1f6 lIbFWC07zd+TfdSF3XBgrzBerb3BeOgGiRB+BDwF/r/aiSE+bgt0QJa50x75LMsHwN95 IGiQ== 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=BdoDM6Fcp+zj8x+ZW8NaeyYQ3wgTOS6KSHp3tHo000o=; b=FrkmSLqLd6T2Z53cIngyXK0d3X34Hch0uPvJ+3H97lP51ae2HGDqh2vTgUcel+pYaf Kkuxf6xqGDIzZTG+lFBLqtsj0Zmf4Tc5dbKTIApLns1riuEBXyqH6JDrLVHznJwdZG7b 7B6f9ffKBMkeI0HuZZensjjm1r6mvKvpq93HhfZ1VeIN4c/FDbVUkrNLFkmM21rNqztD YjBthKD/MRvAgtNVR8Q3J1k7Z0KNUlA/0AAPx94xTavFB1tTtLNMtEqV8xJ50AFxA0ew 8HHZtMNr7vQKzdmmPFdrxcsmj8lDvzluUfdXhD9p6Lg4nrRPPU0oj+qW6w1TGGLxrXVD /p1A== X-Gm-Message-State: AFqh2kozLjvwVK4XazDhPCQHi0WW8Yt1O5fQFctRFelPZE7x7z9BfVn+ f3lgNRQuAovOL01M7mvaXFteeujyvjEGs9Fg6b3i X-Google-Smtp-Source: AMrXdXtq0nmW98SWytYE6VlV0W+8RaegmKLvQsD3vcycHR1IfvVYTVi8QJK8G0UMJvqwYLIFTLy+FA== X-Received: by 2002:a05:600c:4307:b0:3d3:494f:6a39 with SMTP id p7-20020a05600c430700b003d3494f6a39mr41944316wme.16.1673090817464; Sat, 07 Jan 2023 03:26:57 -0800 (PST) Received: from takamaka.gnat.com ([2a01:cb22:1d5:1100:ca82:1b83:d813:c72b]) by smtp.gmail.com with ESMTPSA id j1-20020a05600c1c0100b003cfaae07f68sm10459472wms.17.2023.01.07.03.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 03:26:57 -0800 (PST) Received: by takamaka.gnat.com (Postfix, from userid 1000) id E93A68288F; Sat, 7 Jan 2023 15:26:54 +0400 (+04) Date: Sat, 7 Jan 2023 15:26:54 +0400 From: Joel Brobecker To: Tom Tromey via Gdb-patches Cc: Tom Tromey , Joel Brobecker Subject: Re: [PATCH 3/4] Move hash_entry and eq_entry into cooked_index::do_finalize Message-ID: References: <20221215190759.2494095-1-tromey@adacore.com> <20221215190759.2494095-4-tromey@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221215190759.2494095-4-tromey@adacore.com> X-Spam-Status: No, score=-10.9 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: Hi Tom, On Thu, Dec 15, 2022 at 12:07:58PM -0700, Tom Tromey via Gdb-patches wrote: > 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. Sounds good to me. I think the contextualization of those functions indeed helps understanding what those are for. Thanks for the patch! > --- > 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 > -- Joel