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();
}
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();
}
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits