[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:07:36 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:
Why do we need this `const_cast`? Hmmm looks like `SetVector` not expose a mutable accessor. I think the idea is that you re-insert into the vector, and let the de-duplication mechanism do the right thing.
So i think you want to replace this with a call to `insert`
https://github.com/llvm/llvm-project/pull/181952
More information about the lldb-commits
mailing list