1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[llvm] Populate std::vector at construction time (NFC)

This commit is contained in:
Kazu Hirata 2021-01-18 10:16:33 -08:00
parent a6f855d31d
commit 56ec2fba1e
3 changed files with 5 additions and 10 deletions

View File

@ -63,8 +63,7 @@ static Error writeVariableSizedInteger(uint64_t Integer, size_t Size,
}
static void ZeroFillBytes(raw_ostream &OS, size_t Size) {
std::vector<uint8_t> FillData;
FillData.insert(FillData.begin(), Size, 0);
std::vector<uint8_t> FillData(Size, 0);
OS.write(reinterpret_cast<char *>(FillData.data()), Size);
}

View File

@ -199,14 +199,12 @@ size_t writeLoadCommandData<MachO::build_version_command>(
}
void ZeroFillBytes(raw_ostream &OS, size_t Size) {
std::vector<uint8_t> FillData;
FillData.insert(FillData.begin(), Size, 0);
std::vector<uint8_t> FillData(Size, 0);
OS.write(reinterpret_cast<char *>(FillData.data()), Size);
}
void Fill(raw_ostream &OS, size_t Size, uint32_t Data) {
std::vector<uint32_t> FillData;
FillData.insert(FillData.begin(), (Size / 4) + 1, Data);
std::vector<uint32_t> FillData((Size / 4) + 1, Data);
OS.write(reinterpret_cast<char *>(FillData.data()), Size);
}

View File

@ -287,8 +287,7 @@ std::error_code ProfileSymbolList::read(const uint8_t *Data,
std::error_code ProfileSymbolList::write(raw_ostream &OS) {
// Sort the symbols before output. If doing compression.
// It will make the compression much more effective.
std::vector<StringRef> SortedList;
SortedList.insert(SortedList.begin(), Syms.begin(), Syms.end());
std::vector<StringRef> SortedList(Syms.begin(), Syms.end());
llvm::sort(SortedList);
std::string OutputString;
@ -303,8 +302,7 @@ std::error_code ProfileSymbolList::write(raw_ostream &OS) {
void ProfileSymbolList::dump(raw_ostream &OS) const {
OS << "======== Dump profile symbol list ========\n";
std::vector<StringRef> SortedList;
SortedList.insert(SortedList.begin(), Syms.begin(), Syms.end());
std::vector<StringRef> SortedList(Syms.begin(), Syms.end());
llvm::sort(SortedList);
for (auto &Sym : SortedList)