================
@@ -1218,42 +1268,62 @@ uint32_t SymbolContextList::AppendIfUnique(const
SymbolContextList &sc_list,
bool SymbolContextList::AppendIfUnique(const SymbolContext &sc,
bool merge_symbol_into_function) {
- collection::iterator pos, end = m_symbol_contexts.end();
- for (pos = m_symbol_contexts.begin(); pos != end; ++pos) {
- // Because symbol contexts might first be built without the symbol,
- // which is then appended later on, compare the symbol contexts taking into
- // accout that one (or either) of them might not have a symbol yet.
- if (SymbolContext::CompareConsideringPossiblyNullSymbol(*pos, sc))
+
+ // Look in the set if it's populated, otherwise, fall back to linear scan.
+ if (!m_lookup_set.empty()) {
+ if (m_lookup_set.count(sc))
+ return false;
+ } else if (m_symbol_contexts.size() < kSetThreshold) {
----------------
Michael137 wrote:
Are you doing this threshold switch because you postulate that for a small
number of elements the linear search is more efficient? Or can we just
unconditionally use a set? There's also `llvm::UniqueVector` which might be of
interest to you. It maintains a vector of elements with a backing set to keep
them elements unique.
https://github.com/llvm/llvm-project/pull/181952
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits