From patchwork Mon Mar 24 20:20:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 109121 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 D2EFA3858280 for ; Mon, 24 Mar 2025 20:21:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2EFA3858280 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=default header.b=gwTUTHcx X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 639073858D33 for ; Mon, 24 Mar 2025 20:20:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 639073858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 639073858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742847642; cv=none; b=URaCZ3f/TIa1KccKq542Nc9/AzxnCVg4dnBzWsZGMj3xsI3DZ6RxjFsMw3oxJCTJ/z0Ro+5jwySQ2WPG1mRA34bc25T8LCU3XH7bG+545d5bspJg6LhntUFASwKFIJe3QVK56qcVBssAnD+gE7p9jaCm/pujy1Nvp/yC6p2Djhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742847642; c=relaxed/simple; bh=IhnZLK6QBV4g+Uf0z+W4/TKGOvpBMyy5hfrvInnGwCc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SLoxFOVFFgbJ1k2WPTmsgi6AWzqYcsOJMcLbjegCyGHc6Z1esGgjbRrifPcsVNt4Pr2FNMHOsgPCmsI+FfH+W9Zaisi6W2pO/LiRqSfNZUBP/IuVlRZztv1vFFoUP2/8C/BpldNppCSsBRhEEXHDQwRs535kmhRiu53YbXtLkDk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 639073858D33 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 52OKKbet150831 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 24 Mar 2025 16:20:41 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 52OKKbet150831 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1742847642; bh=i4eZtw0Pu81sVTA9mYnofBXEFXJmVH20i+KBmgYohwQ=; h=From:To:Cc:Subject:Date:From; b=gwTUTHcxh+wJ5znbA7n4kH15KEuwh3FgXtwBLngxGkVXkCzZbYSuCWeR5KNzlRY6P ljAruP1/q+/rdJ5WHG68rC4A45btrfYKH7oBUyZveGyNkQoi5G1GvSrVzhcEgoBkuL fbsXOBZ3U+pQmIg6bFbWtdygh0ndHhLLtResSuDo= Received: by simark.ca (Postfix, from userid 112) id 2B6E11E114; Mon, 24 Mar 2025 16:20:37 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Spam-Level: X-Spam-Status: No, score=-3187.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from simark.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 074FF1E0C0; Mon, 24 Mar 2025 16:20:35 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] gdb/dwarf: remove unnecessary comparison in cooked_index_entry::compare Date: Mon, 24 Mar 2025 16:20:27 -0400 Message-ID: <20250324202035.3727263-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 24 Mar 2025 20:20:37 +0000 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 From: Simon Marchi I believe that the `(mode == MATCH && a == munge ('<'))` part of the condition is unnecesary. Or perhaps I don't understand the algorithm. The use of "munge" above effectively makes it so that the template portion of names is completely ignored for the sake of the comparison. Then, in the condition, this: a == munge ('<') is functionally equivalent to a == '\0' If `a` is indeed '\0', and `b` is also '\0', then we would have taken the earlier branch: if (a == b) return 0; If `b` is not '\0', then we won't take this branch and we'll go into the final comparison: return a < b ? -1 : 1; So, as far as I can see, there is no case where `mode == MATCH`, where we're going to use this special `return 0`. Regression tested using the various DWARF target boards on Debian 12. Change-Id: I5ea0463c1fdbbc1b003de2f0a423fd0073cc9dec --- gdb/dwarf2/cooked-index.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) base-commit: 49d5323352a910dd99cdd635c4923610cce36d10 diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 724615f497e3..1a2e19debab5 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -122,11 +122,8 @@ cooked_index_entry::compare (const char *stra, const char *strb, /* When completing, if STRB ends earlier than STRA, consider them as equal. */ - if (mode == COMPLETE || (mode == MATCH && a == munge ('<'))) - { - if (b == '\0') - return 0; - } + if (mode == COMPLETE && b == '\0') + return 0; return a < b ? -1 : 1; }