]> granicus.if.org Git - clang/commitdiff
Workaround a performance issue with modules + PCH
authorBen Langmuir <blangmuir@apple.com>
Fri, 10 Apr 2015 22:25:42 +0000 (22:25 +0000)
committerBen Langmuir <blangmuir@apple.com>
Fri, 10 Apr 2015 22:25:42 +0000 (22:25 +0000)
More fallout from r228234; when looking up an identifier in a PCH that
imports the Cocoa module on Darwin, it was taking 2 to 5 seconds
because we were hammering the MapVector::erase() function, which is
O(n).  For now, just clear() the contained SmallVector to get back to
0.25 - 0.5 seconds.  This is probably not the long-term fix, because
without modules or without PCH the performance is more like 0.02
seconds.

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

lib/Serialization/ASTReader.cpp

index 034b8a47020798292e95c8ecf35a7bf9b0a7c328..d26ed222b3ac8889793a9294536fbdc0397a624c 100644 (file)
@@ -8668,7 +8668,10 @@ void ASTReader::pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name) {
     if (It != PendingFakeLookupResults.end()) {
       for (auto *ND : PendingFakeLookupResults[II])
         SemaObj->IdResolver.RemoveDecl(ND);
-      PendingFakeLookupResults.erase(It);
+      // FIXME: this works around module+PCH performance issue.
+      // Rather than erase the result from the map, which is O(n), just clear
+      // the vector of NamedDecls.
+      It->second.clear();
     }
   }