From 054cdb34a20de8bed8d119bdffc2dd3220f199fb Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 16 Dec 2021 21:22:59 -0800 Subject: [PATCH] [ELF] Optimize MergeInputSection::splitNonStrings. NFC --- lld/ELF/InputSection.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index baceaa780c6e..820ddae74124 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -1388,8 +1388,9 @@ void MergeInputSection::splitNonStrings(ArrayRef data, assert((size % entSize) == 0); const bool live = !(flags & SHF_ALLOC) || !config->gcSections; - for (size_t i = 0; i != size; i += entSize) - pieces.emplace_back(i, xxHash64(data.slice(i, entSize)), live); + pieces.assign(size / entSize, SectionPiece(0, 0, false)); + for (size_t i = 0, j = 0; i != size; i += entSize, j++) + pieces[j] = {i, (uint32_t)xxHash64(data.slice(i, entSize)), live}; } template