[lld] r205576 - Replace a recursion with a loop for speed.
Rui Ueyama
ruiu at google.com
Thu Apr 3 15:36:56 PDT 2014
Author: ruiu
Date: Thu Apr 3 17:36:55 2014
New Revision: 205576
URL: http://llvm.org/viewvc/llvm-project?rev=205576&view=rev
Log:
Replace a recursion with a loop for speed.
Modified:
lld/trunk/lib/Core/SymbolTable.cpp
Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=205576&r1=205575&r2=205576&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Thu Apr 3 17:36:55 2014
@@ -379,11 +379,13 @@ void SymbolTable::addReplacement(const A
}
const Atom *SymbolTable::replacement(const Atom *atom) {
- AtomToAtom::iterator pos = _replacedAtoms.find(atom);
- if (pos == _replacedAtoms.end())
- return atom;
- // might be chain, recurse to end
- return replacement(pos->second);
+ for (;;) {
+ AtomToAtom::iterator pos = _replacedAtoms.find(atom);
+ if (pos == _replacedAtoms.end())
+ return atom;
+ // might be chain, recurse to end
+ atom = pos->second;
+ }
}
unsigned int SymbolTable::size() {
More information about the llvm-commits
mailing list