[ELF] --gdb-index: switch to SmallVector. NFC

This commit is contained in:
Fangrui Song 2022-01-29 15:24:56 -08:00
parent 81cc834a48
commit 469c4124ab
2 changed files with 12 additions and 12 deletions

View File

@ -2765,13 +2765,13 @@ readAddressAreas(DWARFContext &dwarf, InputSection *sec) {
} }
template <class ELFT> template <class ELFT>
static std::vector<GdbIndexSection::NameAttrEntry> static SmallVector<GdbIndexSection::NameAttrEntry, 0>
readPubNamesAndTypes(const LLDDwarfObj<ELFT> &obj, readPubNamesAndTypes(const LLDDwarfObj<ELFT> &obj,
const SmallVectorImpl<GdbIndexSection::CuEntry> &cus) { const SmallVectorImpl<GdbIndexSection::CuEntry> &cus) {
const LLDDWARFSection &pubNames = obj.getGnuPubnamesSection(); const LLDDWARFSection &pubNames = obj.getGnuPubnamesSection();
const LLDDWARFSection &pubTypes = obj.getGnuPubtypesSection(); const LLDDWARFSection &pubTypes = obj.getGnuPubtypesSection();
std::vector<GdbIndexSection::NameAttrEntry> ret; SmallVector<GdbIndexSection::NameAttrEntry, 0> ret;
for (const LLDDWARFSection *pub : {&pubNames, &pubTypes}) { for (const LLDDWARFSection *pub : {&pubNames, &pubTypes}) {
DWARFDataExtractor data(obj, *pub, config->isLE, config->wordsize); DWARFDataExtractor data(obj, *pub, config->isLE, config->wordsize);
DWARFDebugPubTable table; DWARFDebugPubTable table;
@ -2798,9 +2798,9 @@ readPubNamesAndTypes(const LLDDwarfObj<ELFT> &obj,
// Create a list of symbols from a given list of symbol names and types // Create a list of symbols from a given list of symbol names and types
// by uniquifying them by name. // by uniquifying them by name.
static std::vector<GdbIndexSection::GdbSymbol> static SmallVector<GdbIndexSection::GdbSymbol, 0> createSymbols(
createSymbols(ArrayRef<std::vector<GdbIndexSection::NameAttrEntry>> nameAttrs, ArrayRef<SmallVector<GdbIndexSection::NameAttrEntry, 0>> nameAttrs,
const std::vector<GdbIndexSection::GdbChunk> &chunks) { const SmallVector<GdbIndexSection::GdbChunk, 0> &chunks) {
using GdbSymbol = GdbIndexSection::GdbSymbol; using GdbSymbol = GdbIndexSection::GdbSymbol;
using NameAttrEntry = GdbIndexSection::NameAttrEntry; using NameAttrEntry = GdbIndexSection::NameAttrEntry;
@ -2827,7 +2827,7 @@ createSymbols(ArrayRef<std::vector<GdbIndexSection::NameAttrEntry>> nameAttrs,
size_t shift = 32 - countTrailingZeros(numShards); size_t shift = 32 - countTrailingZeros(numShards);
// Instantiate GdbSymbols while uniqufying them by name. // Instantiate GdbSymbols while uniqufying them by name.
auto symbols = std::make_unique<std::vector<GdbSymbol>[]>(numShards); auto symbols = std::make_unique<SmallVector<GdbSymbol, 0>[]>(numShards);
parallelForEachN(0, concurrency, [&](size_t threadId) { parallelForEachN(0, concurrency, [&](size_t threadId) {
uint32_t i = 0; uint32_t i = 0;
@ -2857,9 +2857,9 @@ createSymbols(ArrayRef<std::vector<GdbIndexSection::NameAttrEntry>> nameAttrs,
// The return type is a flattened vector, so we'll copy each vector // The return type is a flattened vector, so we'll copy each vector
// contents to Ret. // contents to Ret.
std::vector<GdbSymbol> ret; SmallVector<GdbSymbol, 0> ret;
ret.reserve(numSymbols); ret.reserve(numSymbols);
for (std::vector<GdbSymbol> &vec : for (SmallVector<GdbSymbol, 0> &vec :
makeMutableArrayRef(symbols.get(), numShards)) makeMutableArrayRef(symbols.get(), numShards))
for (GdbSymbol &sym : vec) for (GdbSymbol &sym : vec)
ret.push_back(std::move(sym)); ret.push_back(std::move(sym));
@ -2906,8 +2906,8 @@ template <class ELFT> GdbIndexSection *GdbIndexSection::create() {
return !s->isLive(); return !s->isLive();
}); });
std::vector<GdbChunk> chunks(files.size()); SmallVector<GdbChunk, 0> chunks(files.size());
std::vector<std::vector<NameAttrEntry>> nameAttrs(files.size()); SmallVector<SmallVector<NameAttrEntry, 0>, 0> nameAttrs(files.size());
parallelForEachN(0, files.size(), [&](size_t i) { parallelForEachN(0, files.size(), [&](size_t i) {
// To keep memory usage low, we don't want to keep cached DWARFContext, so // To keep memory usage low, we don't want to keep cached DWARFContext, so

View File

@ -820,10 +820,10 @@ private:
// Each chunk contains information gathered from debug sections of a // Each chunk contains information gathered from debug sections of a
// single object file. // single object file.
std::vector<GdbChunk> chunks; SmallVector<GdbChunk, 0> chunks;
// A symbol table for this .gdb_index section. // A symbol table for this .gdb_index section.
std::vector<GdbSymbol> symbols; SmallVector<GdbSymbol, 0> symbols;
size_t size; size_t size;
}; };