mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[NFC] Refactor manual size calculations in memory allocation (#33256)
This commit is contained in:
@@ -139,12 +139,9 @@ ImportCache::getImportSet(ASTContext &ctx,
|
||||
// getImportedModulesForLookup().
|
||||
if (ImportSet *result = ImportSets.FindNodeOrInsertPos(ID, InsertPos))
|
||||
return *result;
|
||||
|
||||
void *mem = ctx.Allocate(
|
||||
sizeof(ImportSet) +
|
||||
sizeof(ModuleDecl::ImportedModule) * topLevelImports.size() +
|
||||
sizeof(ModuleDecl::ImportedModule) * transitiveImports.size(),
|
||||
alignof(ImportSet), AllocationArena::Permanent);
|
||||
|
||||
size_t bytes = ImportSet::totalSizeToAlloc<ModuleDecl::ImportedModule>(topLevelImports.size() + transitiveImports.size());
|
||||
void *mem = ctx.Allocate(bytes, alignof(ImportSet), AllocationArena::Permanent);
|
||||
|
||||
auto *result = new (mem) ImportSet(hasHeaderImportModule,
|
||||
topLevelImports,
|
||||
|
||||
Reference in New Issue
Block a user