[lld] r205576 - Replace a recursion with a loop for speed.
Rui Ueyama
ruiu at google.com
Thu Apr 3 16:05:32 PDT 2014
On Thu, Apr 3, 2014 at 3:55 PM, David Blaikie <dblaikie at gmail.com> wrote:
> On Thu, Apr 3, 2014 at 3:36 PM, Rui Ueyama <ruiu at google.com> wrote:
> > 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
>
> Not sure if you want to update this comment now that the algorithm
> isn't stack recursive ("recurse" might still be the most suitable way
> to describe this algorithm, I don't know)
Thanks. Updated the comment in r205579.
> > + atom = pos->second;
> > + }
> > }
> >
> > unsigned int SymbolTable::size() {
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140403/af548d82/attachment.html>
More information about the llvm-commits
mailing list