This revision was automatically updated to reflect the committed changes.
Closed by commit rL370879: [lldb] Early exit in 
RangeDataVector:FindEntryIndexesThatContain (authored by teemperor, committed 
by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67123?vs=218644&id=218645#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67123

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


Index: lldb/trunk/include/lldb/Utility/RangeMap.h
===================================================================
--- lldb/trunk/include/lldb/Utility/RangeMap.h
+++ lldb/trunk/include/lldb/Utility/RangeMap.h
@@ -724,12 +724,14 @@
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
     assert(IsSorted());
 #endif
-
-    if (!m_entries.empty()) {
-      for (const auto &entry : m_entries) {
-        if (entry.Contains(addr))
-          indexes.push_back(entry.data);
-      }
+    // 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();
   }


Index: lldb/trunk/include/lldb/Utility/RangeMap.h
===================================================================
--- lldb/trunk/include/lldb/Utility/RangeMap.h
+++ lldb/trunk/include/lldb/Utility/RangeMap.h
@@ -724,12 +724,14 @@
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
     assert(IsSorted());
 #endif
-
-    if (!m_entries.empty()) {
-      for (const auto &entry : m_entries) {
-        if (entry.Contains(addr))
-          indexes.push_back(entry.data);
-      }
+    // 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();
   }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to