[CodeView] Reserve TypeDatabase records up front.
Most of the time we know exactly how many type records we
have in a list, and we want to use the visitor to deserialize
them into actual records in a database. Previously we were
just using push_back() every time without reserving the space
up front in the vector. This is obviously terrible from a
performance standpoint, and it's not uncommon to have PDB
files with half a million type records, where the performance
degredation was quite noticeable.
llvm-svn: 302302
diff --git a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index ca7efa6..2dd4ef0 100644
--- a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -631,7 +631,7 @@
Visitors.push_back(make_unique<TypeDeserializer>());
if (!StreamDB.hasValue()) {
- StreamDB.emplace();
+ StreamDB.emplace(Tpi->getNumTypeRecords());
Visitors.push_back(make_unique<TypeDatabaseVisitor>(*StreamDB));
}
// If we're in dump mode, add a dumper with the appropriate detail level.
@@ -722,14 +722,14 @@
if (DB.hasValue())
return Error::success();
- DB.emplace();
-
auto Tpi =
(SN == StreamTPI) ? File.getPDBTpiStream() : File.getPDBIpiStream();
if (!Tpi)
return Tpi.takeError();
+ DB.emplace(Tpi->getNumTypeRecords());
+
TypeVisitorCallbackPipeline Pipeline;
TypeDeserializer Deserializer;
TypeDatabaseVisitor DBV(*DB);