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.

llvm-svn: 168394
This commit is contained in:
Rafael Espindola 2012-11-20 23:23:57 +00:00
parent 3a6808cc32
commit cd7720a03f
1 changed files with 2 additions and 2 deletions

View File

@ -3299,10 +3299,10 @@ void Redeclarable<decl_type>::setPreviousDeclaration(decl_type *PrevDecl) {
// 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);