[ELF] Improve 2 SmallVector<*, N> usage
authorFangrui Song <i@maskray.me>
Sun, 29 Nov 2020 22:01:32 +0000 (14:01 -0800)
committerFangrui Song <i@maskray.me>
Sun, 29 Nov 2020 22:01:32 +0000 (14:01 -0800)
For --gc-sections, SmallVector<InputSection *, 256> -> SmallVector<InputSection *, 0> because the code bloat (1296 bytes) is not worthwhile (the saved reallocation is negligible).
For OutputSection::compressedData, N=1 is useless (for a compressed .debug_*, the size is always larger than 1).

lld/ELF/MarkLive.cpp
lld/ELF/OutputSections.h

index 2c350e2..35220e1 100644 (file)
@@ -65,7 +65,7 @@ private:
   unsigned partition;
 
   // A list of sections to visit.
-  SmallVector<InputSection *, 256> queue;
+  SmallVector<InputSection *, 0> queue;
 
   // There are normally few input sections whose names are valid C
   // identifiers, so we just store a std::vector instead of a multimap.
index d5686f1..39bf48c 100644 (file)
@@ -111,7 +111,7 @@ public:
 private:
   // Used for implementation of --compress-debug-sections option.
   std::vector<uint8_t> zDebugHeader;
-  llvm::SmallVector<char, 1> compressedData;
+  llvm::SmallVector<char, 0> compressedData;
 
   std::array<uint8_t, 4> getFiller();
 };