Skip to content

Commit

Permalink
[ELF] GnuHashTableSection: replace stable_sort with 2-key sort. NFC
Browse files Browse the repository at this point in the history
strTabOffset stabilizes llvm::sort. My x86-64 executable is 5+KiB smaller.
  • Loading branch information
MaskRay committed Jan 17, 2022
1 parent 4796b4a commit f855074
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lld/ELF/SyntheticSections.cpp
Expand Up @@ -2478,8 +2478,9 @@ void GnuHashTableSection::addSymbols(SmallVectorImpl<SymbolTableEntry> &v) {
symbols.push_back({b, ent.strTabOffset, hash, bucketIdx});
}

llvm::stable_sort(symbols, [](const Entry &l, const Entry &r) {
return l.bucketIdx < r.bucketIdx;
llvm::sort(symbols, [](const Entry &l, const Entry &r) {
return std::tie(l.bucketIdx, l.strTabOffset) <
std::tie(r.bucketIdx, r.strTabOffset);
});

v.erase(mid, v.end());
Expand Down

0 comments on commit f855074

Please sign in to comment.