From patchwork Wed Jan 8 07:23:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 104318 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4ECAE3858C60 for ; Wed, 8 Jan 2025 07:27:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4ECAE3858C60 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=aHtHpOiC X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 4CC303858C32 for ; Wed, 8 Jan 2025 07:23:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CC303858C32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4CC303858C32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736321008; cv=none; b=EksY7RAUJIuTPhZcEqE7JhB7jlXHfe6hkW1DG5C+ROM/HvRBTwvv1vHo2Fll+mRx24+z1bVa1oF2GJy7SLn6RjpkAYFg1Hgnhgkj//T6t/veN4FuQNDszNYBE4hVDMOOyD97xyGjJZ09YuiFCk2BoUDmUbOkvEchSFn6WwUGl0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736321008; c=relaxed/simple; bh=32vJXpDtuXDfkVeJs+AnO9mL6cvuYq3V18CFQgAC9SM=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=U5Rjv06QOV6QpWpSpnIt5tMFciY9yGeyJAeH0Iw1dvNTGKUmMgp5VcMO/hMJ49ZDkr1Exa4XEXErWTOfu8U+WUtl72/dVlu72BudDvRx6mO8klIleQrXyMRI/9ch+ms2rLr7WdkmFLNJuOgKHG7jgemTp7TqEIKP0JkGutXIVJs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CC303858C32 Received: from eig-obgw-6005a.ext.cloudfilter.net ([10.0.30.201]) by cmsmtp with ESMTPS id VL1CtQlEjYpSZVQPXt6AA5; Wed, 08 Jan 2025 07:23:27 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id VQPWtG6S8IQeVVQPWtzZ1H; Wed, 08 Jan 2025 07:23:27 +0000 X-Authority-Analysis: v=2.4 cv=cLYrsUeN c=1 sm=1 tr=0 ts=677e27ef a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=VdSt8ZQiCzkA:10 a=ItBw4LHWJt0A:10 a=EuqcBZHCz_egLTRmhbYA:9 a=QEXdDO2ut3YA:10 a=6Ogn3jAGHLSNbaov7Orx:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1pdZSoqkOa4xZ4KubkmGpPReg8BhZ4U72UkuUtbHlvA=; b=aHtHpOiCTHOWpMZVonq080YHRF 3rctoO6/r0YkKNKwchy1yO3PcInmiYoUjOK7fvj1blN5avkp91tgecobgn3U77uIGas5Zf8M1OWu3 Q9nucUmsP38FghEbfzGY8CMx2; Received: from 97-118-36-154.hlrn.qwest.net ([97.118.36.154]:56396 helo=prentzel.local) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1tVQPW-001pZ1-0m; Wed, 08 Jan 2025 00:23:26 -0700 From: Tom Tromey Date: Wed, 08 Jan 2025 00:23:25 -0700 Subject: [PATCH 5/6] Hoist lambda in linespec.c:add_matching_symbols_to_info MIME-Version: 1.0 Message-Id: <20250108-linespec-state-cxx-v1-5-a721e95ee050@tromey.com> References: <20250108-linespec-state-cxx-v1-0-a721e95ee050@tromey.com> In-Reply-To: <20250108-linespec-state-cxx-v1-0-a721e95ee050@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.118.36.154 X-Source-L: No X-Exim-ID: 1tVQPW-001pZ1-0m X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-36-154.hlrn.qwest.net (prentzel.local) [97.118.36.154]:56396 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBp3unaHRd7J3ygSz+gUNwNUwAVa+Iy05CGgFLm1gDnGb7odeRhIuX3SgqLzWcW9tqFm/Af92LXwNOlsTPLia4Glskj6Af8tImHNPAF5VqEC5LmDCqmx jkw96IeTfgMa8uaOvWBsny5eFTdWXyDJP8r7fYENbUaIb++GgrnFI0IkIwgoeO+XiuhLDgHJQzcMmJSVg44XhcfLf17OJqs4N5A= X-Spam-Status: No, score=-3019.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org I noticed that two parts of linespec.c:add_matching_symbols_to_info use the same lambda, and hoisting this seems slightly more efficient. --- gdb/linespec.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 4f80a42484fef33bed5b4c9f36e78486bbd4f97d..9b1e1856eff349d567d4f918b85a79e8323e247f 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -4277,6 +4277,11 @@ add_matching_symbols_to_info (const char *name, { lookup_name_info lookup_name (name, name_match_type); + auto add_symbol = [&] (block_symbol *bsym) + { + return info->add_symbol (bsym); + }; + for (const auto &elt : *info->file_symtabs) { if (elt == nullptr) @@ -4284,8 +4289,7 @@ add_matching_symbols_to_info (const char *name, iterate_over_all_matching_symtabs (info->state, lookup_name, domain_search_flags, pspace, true, - [&] (block_symbol *bsym) - { return info->add_symbol (bsym); }); + add_symbol); search_minsyms_for_name (info, lookup_name, pspace, NULL); } else if (pspace == NULL || pspace == elt->compunit ()->objfile ()->pspace ()) @@ -4297,9 +4301,7 @@ add_matching_symbols_to_info (const char *name, program_space *elt_pspace = elt->compunit ()->objfile ()->pspace (); gdb_assert (!elt_pspace->executing_startup); set_current_program_space (elt_pspace); - iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT, - [&] (block_symbol *bsym) - { return info->add_symbol (bsym); }); + iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT, add_symbol); /* If no new symbols were found in this iteration and this symtab is in assembler, we might actually be looking for a label for