[Lldb-commits] [PATCH] D67123: [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 4 00:37:11 PDT 2019


teemperor updated this revision to Diff 218602.
teemperor retitled this revision from "[lldb] Use binary search in RangeDataVector:FindEntryIndexesThatContain" to "[lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain".
teemperor edited the summary of this revision.
teemperor added a comment.

- Refactor to just stop the search when we find a higher base address.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67123/new/

https://reviews.llvm.org/D67123

Files:
  lldb/include/lldb/Utility/RangeMap.h


Index: lldb/include/lldb/Utility/RangeMap.h
===================================================================
--- lldb/include/lldb/Utility/RangeMap.h
+++ lldb/include/lldb/Utility/RangeMap.h
@@ -725,11 +725,17 @@
     assert(IsSorted());
 #endif
 
-    if (!m_entries.empty()) {
-      for (const auto &entry : m_entries) {
-        if (entry.Contains(addr))
-          indexes.push_back(entry.data);
-      }
+    if (m_entries.empty())
+      return indexes.size();
+
+    // Search the entries until the first entry that has a larger base address
+    // than `addr`. As m_entries is sorted by their base address, all following
+    // entries can't contain `addr` as their base address is already larger.
+    for (const auto &entry : m_entries) {
+      if (entry.Contains(addr))
+        indexes.push_back(entry.data);
+      else if (entry.GetRangeBase() > addr)
+        break;
     }
     return indexes.size();
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67123.218602.patch
Type: text/x-patch
Size: 929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190904/79357885/attachment.bin>


More information about the lldb-commits mailing list