[lld] 054cdb3 - [ELF] Optimize MergeInputSection::splitNonStrings. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 16 21:23:06 PST 2021


Author: Fangrui Song
Date: 2021-12-16T21:23:00-08:00
New Revision: 054cdb34a20de8bed8d119bdffc2dd3220f199fb

URL: https://github.com/llvm/llvm-project/commit/054cdb34a20de8bed8d119bdffc2dd3220f199fb
DIFF: https://github.com/llvm/llvm-project/commit/054cdb34a20de8bed8d119bdffc2dd3220f199fb.diff

LOG: [ELF] Optimize MergeInputSection::splitNonStrings. NFC

Added: 
    

Modified: 
    lld/ELF/InputSection.cpp

Removed: 
    


################################################################################
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<uint8_t> 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 <class ELFT>


        


More information about the llvm-commits mailing list