From: Simon Marchi Date: Tue, 3 Dec 2019 20:19:35 +0000 (-0500) Subject: Make find_thread_ptid lookup thread map instead of iterate X-Git-Url: http://git.efficios.com/?p=deliverable%2Fbinutils-gdb.git;a=commitdiff_plain;h=4c449d978ae4916445678ca41993d280aa6854ed 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. --- diff --git a/gdb/thread.c b/gdb/thread.c index 487626619f..a0c4a45a20 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -530,11 +530,11 @@ find_thread_ptid (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. */