aboutsummaryrefslogtreecommitdiffstats
path: root/include/lldb/Utility/RangeMap.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Utility/RangeMap.h')
-rw-r--r--include/lldb/Utility/RangeMap.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/include/lldb/Utility/RangeMap.h b/include/lldb/Utility/RangeMap.h
index 36401f59d34f..709b5d2f66c7 100644
--- a/include/lldb/Utility/RangeMap.h
+++ b/include/lldb/Utility/RangeMap.h
@@ -724,12 +724,14 @@ public:
#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();
}