From 2301204a3b3cd6553f7490498b3adc5973157c1b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 3 Dec 2019 15:19:35 -0500 Subject: [PATCH] Make find_thread_ptid lookup thread map instead of iterate Now that inferior threads are stored in a map, change the find_thread_ptid function to look up a thread using std::map::find, instead of iterating on all of the inferior's threads. --- gdb/thread.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gdb/thread.c b/gdb/thread.c index 20b83ea3af..f0d331ee3a 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -533,11 +533,11 @@ find_thread_ptid (process_stratum_target *targ, ptid_t ptid) struct thread_info * find_thread_ptid (inferior *inf, ptid_t ptid) { - for (thread_info *tp : inf->threads ()) - if (tp->ptid == ptid) - return tp; - - return NULL; + auto it = inf->thread_map.find (ptid); + if (it != inf->thread_map.end ()) + return it->second; + else + return nullptr; } /* See gdbthread.h. */ -- 2.34.1