ASTWriter: Cache some DenseMaps we use repeatedly.
- This reduces our total # of allocations building a PCH for Cocoa.h by almost a whopping 50%. - A SmallPtrMap would be cleaner, but since we don't have one yet... llvm-svn: 151697
This commit is contained in:
parent
7e4b976c36
commit
a5acaa3ca8
|
@ -207,6 +207,18 @@ private:
|
|||
/// IdentifierInfo.
|
||||
llvm::DenseMap<const IdentifierInfo *, serialization::IdentID> IdentifierIDs;
|
||||
|
||||
/// @name FlushStmt Caches
|
||||
/// @{
|
||||
|
||||
/// \brief Set of parent Stmts for the currently serializing sub stmt.
|
||||
llvm::DenseSet<Stmt *> ParentStmts;
|
||||
|
||||
/// \brief Offsets of sub stmts already serialized. The offset points
|
||||
/// just after the stmt record.
|
||||
llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \brief Offsets of each of the identifier IDs into the identifier
|
||||
/// table.
|
||||
std::vector<uint32_t> IdentifierOffsets;
|
||||
|
|
|
@ -1586,11 +1586,10 @@ void ASTWriter::WriteSubStmt(Stmt *S,
|
|||
void ASTWriter::FlushStmts() {
|
||||
RecordData Record;
|
||||
|
||||
/// \brief Set of parent Stmts for the currently serializing sub stmt.
|
||||
llvm::DenseSet<Stmt *> ParentStmts;
|
||||
/// \brief Offsets of sub stmts already serialized. The offset points
|
||||
/// just after the stmt record.
|
||||
llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries;
|
||||
// We expect to be the only consumer of the two temporary statement maps,
|
||||
// assert that they are empty.
|
||||
assert(SubStmtEntries.empty() && "unexpected entries in sub stmt map");
|
||||
assert(ParentStmts.empty() && "unexpected entries in parent stmt map");
|
||||
|
||||
for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
|
||||
WriteSubStmt(StmtsToEmit[I], SubStmtEntries, ParentStmts);
|
||||
|
|
Loading…
Reference in New Issue