summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-09-04 11:40:29 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-09-04 11:40:29 +0000
commite36fd9ed7602b8c78c6c0ba9103bba59b65b4556 (patch)
tree4e09f6e8e7dc0db382c8bd13019b46c190895ad2
parent75d734475a4f67a5deb35322c1386c77f17ad942 (diff)
downloadbcm5719-llvm-e36fd9ed7602b8c78c6c0ba9103bba59b65b4556.tar.gz
bcm5719-llvm-e36fd9ed7602b8c78c6c0ba9103bba59b65b4556.zip
[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 llvm-svn: 370879
-rw-r--r--lldb/include/lldb/Utility/RangeMap.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/lldb/include/lldb/Utility/RangeMap.h b/lldb/include/lldb/Utility/RangeMap.h
index 36401f59d34..709b5d2f66c 100644
--- a/lldb/include/lldb/Utility/RangeMap.h
+++ b/lldb/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();
}
OpenPOWER on IntegriCloud