aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2022-11-18 11:09:11 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2022-11-18 11:09:11 -0500
commitd4895ba2df3bbf38d64fce314f5933d05eb8990a (patch)
tree7c86fc2fcc261c763f06fa57a3c31ea5d19418ed
parent6533cbeeb831224e2d2dd2a7bea54b22b798fa39 (diff)
downloadfsf-binutils-gdb-d4895ba2df3bbf38d64fce314f5933d05eb8990a.zip
fsf-binutils-gdb-d4895ba2df3bbf38d64fce314f5933d05eb8990a.tar.gz
fsf-binutils-gdb-d4895ba2df3bbf38d64fce314f5933d05eb8990a.tar.bz2
gdbserver/linux: take condition out of callback in find_lwp_pid
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. Reviewed-By: Andrew Burgess <aburgess@redhat.com> Change-Id: I181670ce1f90b59cb09ea4899367750be2ad9105
-rw-r--r--gdbserver/linux-low.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 0cbfeb9..a896b37 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;
});