[Lldb-commits] [lldb] [lldb] Speed up SymbolContextList::AppendIfUnique (PR #181952)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 20 00:12:26 PST 2026
================
@@ -453,13 +456,20 @@ class SymbolContextList {
/// The zero based index into the symbol context list.
///
/// \return
- /// A const reference to the symbol context to fill in.
- SymbolContext &operator[](size_t idx) { return m_symbol_contexts[idx]; }
-
+ /// A const reference to the symbol context.
const SymbolContext &operator[](size_t idx) const {
return m_symbol_contexts[idx];
}
+ /// Replace the symbol in the symbol context at index \a idx.
+ ///
+ /// The symbol field is excluded from the hash and equality used by the
+ /// internal set, so this is the only mutation that is safe to perform on
+ /// an element that is already in the list.
+ void SetSymbolAtIndex(size_t idx, Symbol *symbol) {
+ const_cast<SymbolContext &>(m_symbol_contexts[idx]).symbol = symbol;
----------------
Michael137 wrote:
Hmm what we'd want is an `insert_or_assign` method. Maybe that'd be not too difficult to contribute?
I don't think it's technically UB, but if we can avoid doing it that'd be great.
https://github.com/llvm/llvm-project/pull/181952
More information about the lldb-commits
mailing list