From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id B309D3852C55 for ; Thu, 17 Nov 2022 19:42:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B309D3852C55 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com X-ASG-Debug-ID: 1668714162-0c856e02a015b8e0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id mjuD8jHmbS5nNG8b (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Thu, 17 Nov 2022 14:42:42 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 82BFE441D64; Thu, 17 Nov 2022 14:42:42 -0500 (EST) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/8] gdbserver/linux: take condition out of callback in find_lwp_pid Date: Thu, 17 Nov 2022 14:42:37 -0500 X-ASG-Orig-Subj: [PATCH 4/8] gdbserver/linux: take condition out of callback in find_lwp_pid Message-Id: <20221117194241.1776125-5-simon.marchi@efficios.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221117194241.1776125-1-simon.marchi@efficios.com> References: <20221117194241.1776125-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1668714162 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 957 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102207 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_SOFTFAIL,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: Just a small optimization, it's not necessary to recompute lwp at each iteration. While at it, change the variable type to long, as ptid_t::lwp returns a long. Change-Id: I181670ce1f90b59cb09ea4899367750be2ad9105 --- gdbserver/linux-low.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 0cbfeb99086..a896b37528b 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -1731,9 +1731,9 @@ linux_process_target::status_pending_p_callback (thread_info *thread, struct lwp_info * find_lwp_pid (ptid_t ptid) { - thread_info *thread = find_thread ([&] (thread_info *thr_arg) + long lwp = ptid.lwp () != 0 ? ptid.lwp () : ptid.pid (); + thread_info *thread = find_thread ([lwp] (thread_info *thr_arg) { - int lwp = ptid.lwp () != 0 ? ptid.lwp () : ptid.pid (); return thr_arg->id.lwp () == lwp; }); -- 2.37.3