Make find_thread_ptid lookup thread map instead of iterate
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 3 Dec 2019 20:19:35 +0000 (15:19 -0500)
committerLaurent Morichetti <laurent.morichetti@amd.com>
Thu, 23 Apr 2020 22:21:28 +0000 (15:21 -0700)
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.

Change-Id: I0041380775fa2bfffdb6e78847d980015b670708

gdb/thread.c

index 0026205e3391850f4b4c3b05c2111945ededa556..036e35887cffcdc7823eda03fc5650bd56580c1d 100644 (file)
@@ -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.  */
This page took 0.025084 seconds and 4 git commands to generate.