[clang] [clang][modules] Shrink the size of `Module::Headers` (PR #113395)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 22 23:46:35 PDT 2024


================
@@ -271,8 +271,22 @@ class alignas(8) Module {
     DirectoryEntryRef Entry;
   };
 
-  /// The headers that are part of this module.
-  SmallVector<Header, 2> Headers[5];
+private:
+  unsigned HeaderKindBeginIndex[6] = {};
+  SmallVector<Header, 2> HeadersStorage;
+
+public:
+  ArrayRef<Header> getHeaders(HeaderKind HK) const {
+    auto BeginIt = HeadersStorage.begin() + HeaderKindBeginIndex[HK];
----------------
cor3ntin wrote:

I think we should assert that `HK is < NumHeaderKinds`

https://github.com/llvm/llvm-project/pull/113395


More information about the cfe-commits mailing list