[llvm] [llvm-symbolizer] nfc, use map instead of vector (PR #69552)
Chen Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 19 01:53:59 PDT 2023
================
@@ -82,12 +82,8 @@ class SymbolizableObjectFile : public SymbolizableModule {
// Non-zero if this is an ELF local symbol. See the comment in
// getNameFromSymbolTable.
uint32_t ELFLocalSymIdx;
-
- bool operator<(const SymbolDesc &RHS) const {
- return Addr != RHS.Addr ? Addr < RHS.Addr : Size < RHS.Size;
- }
};
- std::vector<SymbolDesc> Symbols;
+ std::map<uint64_t, SymbolDesc> Symbols;
----------------
chenzheng1030 wrote:
I think `map` is better than [sorted vector](https://llvm.org/docs/ProgrammersManual.html#a-sorted-vector) for my case. In https://github.com/llvm/llvm-project/pull/69553, when add a new symbol, I need to know if there is any existing symbol that has same address. If I am understanding sorted vector right, each time when a new symbol is inserted to a sorted vector, it has to be sorted manually and then for a new insertion, use a log(n) query(std::lower_bound) to check if the address already exists. I don't see the benefit compared with `map`.
https://github.com/llvm/llvm-project/pull/69552
More information about the llvm-commits
mailing list