mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Use local BumpPtrAllocator for fixed-sized buffers
...instead of std::vector, which (1) will always make separate allocations, and (2) has features and overhead we don't need I don't expect this to actually affect performance too much, but it seems more correct for what Serialization needs anyway.
This commit is contained in:
@@ -796,19 +796,19 @@ bool ModuleFile::readIndexBlock(llvm::BitstreamCursor &cursor) {
|
||||
switch (kind) {
|
||||
case index_block::DECL_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
Decls.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(Decls, scratch);
|
||||
break;
|
||||
case index_block::DECL_CONTEXT_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
DeclContexts.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(DeclContexts, scratch);
|
||||
break;
|
||||
case index_block::TYPE_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
Types.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(Types, scratch);
|
||||
break;
|
||||
case index_block::IDENTIFIER_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
Identifiers.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(Identifiers, scratch);
|
||||
break;
|
||||
case index_block::TOP_LEVEL_DECLS:
|
||||
TopLevelDecls = readDeclTable(scratch, blobData);
|
||||
@@ -836,7 +836,7 @@ bool ModuleFile::readIndexBlock(llvm::BitstreamCursor &cursor) {
|
||||
setEntryPointClassID(scratch.front());
|
||||
break;
|
||||
case index_block::ORDERED_TOP_LEVEL_DECLS:
|
||||
OrderedTopLevelDecls.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(OrderedTopLevelDecls, scratch);
|
||||
break;
|
||||
case index_block::LOCAL_TYPE_DECLS:
|
||||
LocalTypeDecls = readLocalDeclTable(scratch, blobData);
|
||||
@@ -849,27 +849,27 @@ bool ModuleFile::readIndexBlock(llvm::BitstreamCursor &cursor) {
|
||||
break;
|
||||
case index_block::LOCAL_DECL_CONTEXT_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
LocalDeclContexts.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(LocalDeclContexts, scratch);
|
||||
break;
|
||||
case index_block::GENERIC_SIGNATURE_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
GenericSignatures.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(GenericSignatures, scratch);
|
||||
break;
|
||||
case index_block::GENERIC_ENVIRONMENT_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
GenericEnvironments.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(GenericEnvironments, scratch);
|
||||
break;
|
||||
case index_block::SUBSTITUTION_MAP_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
SubstitutionMaps.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(SubstitutionMaps, scratch);
|
||||
break;
|
||||
case index_block::NORMAL_CONFORMANCE_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
NormalConformances.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(NormalConformances, scratch);
|
||||
break;
|
||||
case index_block::SIL_LAYOUT_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
SILLayouts.assign(scratch.begin(), scratch.end());
|
||||
allocateBuffer(SILLayouts, scratch);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user