]> granicus.if.org Git - clang/commitdiff
Modules: Fix a minor performance bug from r293393
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sun, 29 Jan 2017 04:42:21 +0000 (04:42 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sun, 29 Jan 2017 04:42:21 +0000 (04:42 +0000)
Oops... r293393 started calling ReadSignature in
ModuleManager::addModule even when there was no ExpectedSignature.

Whether or not this would have a measurable performance impact (I
spotted this by inspection, and ReadSignature should be fairly fast), we
might as well get what we can.  Add an extra check against
ExpectedSignature to avoid the hit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293415 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ModuleManager.cpp

index 84cdd90182ff601d4c493885eb4c56cbbb98f63d..b7ee30254ff1eea7d9d5b91c2f71a609893da304 100644 (file)
@@ -165,9 +165,10 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
   // Initialize the stream.
   NewModule->Data = PCHContainerRdr.ExtractPCH(*NewModule->Buffer);
 
-  // Read the signature eagerly now so that we can check it.
-  if (checkSignature(ReadSignature(NewModule->Data), ExpectedSignature,
-                     ErrorStr))
+  // Read the signature eagerly now so that we can check it.  Avoid calling
+  // ReadSignature unless there's something to check though.
+  if (ExpectedSignature && checkSignature(ReadSignature(NewModule->Data),
+                                          ExpectedSignature, ErrorStr))
     return OutOfDate;
 
   // We're keeping this module.  Store it everywhere.