Skip to content

Commit

Permalink
[ELF] sortSymTabSymbols: change vector to SmallVector
Browse files Browse the repository at this point in the history
This function may take ~1% time. SmallVector<SymbolTableEntry, 0> is smaller (16 bytes
instead of 24) and more efficient.
  • Loading branch information
MaskRay committed Dec 26, 2021
1 parent d5e310b commit 2c8ebab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lld/ELF/SyntheticSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2127,12 +2127,12 @@ void SymbolTableBaseSection::sortSymTabSymbols() {
// symbols, they are already naturally placed first in each group. That
// happens because STT_FILE is always the first symbol in the object and hence
// precede all other local symbols we add for a file.
MapVector<InputFile *, std::vector<SymbolTableEntry>> arr;
MapVector<InputFile *, SmallVector<SymbolTableEntry, 0>> arr;
for (const SymbolTableEntry &s : llvm::make_range(symbols.begin(), e))
arr[s.sym->file].push_back(s);

auto i = symbols.begin();
for (std::pair<InputFile *, std::vector<SymbolTableEntry>> &p : arr)
for (auto &p : arr)
for (SymbolTableEntry &entry : p.second)
*i++ = entry;
}
Expand Down

0 comments on commit 2c8ebab

Please sign in to comment.