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)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 19 Dec 2019 19:20:53 +0000 (14:20 -0500)
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

index 487626619ffa76a6ebee7378637874b6237a0f68..a0c4a45a2013caa06181b0585a54075c796a438a 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.025478 seconds and 4 git commands to generate.