[Lldb-commits] [lldb] r370879 - [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 4 04:40:29 PDT 2019
Author: teemperor
Date: Wed Sep 4 04:40:29 2019
New Revision: 370879
URL: http://llvm.org/viewvc/llvm-project?rev=370879&view=rev
Log:
[lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain
Summary:
We currently spend a lot of time in this function (around 27% of the br-by-regex benchmark in lldb-bench)
by just iterating over all the ranges. We already sorted these ranges by their base address, we we can actually
just stop checking ranges as soon as we find one that has a higher base address.
Reviewers: labath
Reviewed By: labath
Subscribers: amccarth, arphaman, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D67123
Modified:
lldb/trunk/include/lldb/Utility/RangeMap.h
Modified: lldb/trunk/include/lldb/Utility/RangeMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/RangeMap.h?rev=370879&r1=370878&r2=370879&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/RangeMap.h (original)
+++ lldb/trunk/include/lldb/Utility/RangeMap.h Wed Sep 4 04:40:29 2019
@@ -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();
}
More information about the lldb-commits
mailing list