[cfe-commits] r168394 - /cfe/trunk/include/clang/AST/Decl.h

Rafael Espindola rafael.espindola at gmail.com
Tue Nov 20 15:23:57 PST 2012


Author: rafael
Date: Tue Nov 20 17:23:57 2012
New Revision: 168394

URL: http://llvm.org/viewvc/llvm-project?rev=168394&view=rev
Log:
Don't walk a linked list twice in the same function. On my machine this takes
"clang -cc1" on a file with 10k repetitions of
extern int no_such_variable;
from 1.434s to 1.133s.

Modified:
    cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=168394&r1=168393&r2=168394&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Nov 20 17:23:57 2012
@@ -3299,10 +3299,10 @@
     // Point to previous. Make sure that this is actually the most recent
     // redeclaration, or we can build invalid chains. If the most recent
     // redeclaration is invalid, it won't be PrevDecl, but we want it anyway.
-    RedeclLink = PreviousDeclLink(
-                   llvm::cast<decl_type>(PrevDecl->getMostRecentDecl()));
     First = PrevDecl->getFirstDeclaration();
     assert(First->RedeclLink.NextIsLatest() && "Expected first");
+    decl_type *MostRecent = First->RedeclLink.getNext();
+    RedeclLink = PreviousDeclLink(llvm::cast<decl_type>(MostRecent));
   } else {
     // Make this first.
     First = static_cast<decl_type*>(this);





More information about the cfe-commits mailing list