<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 3, 2014 at 3:55 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On Thu, Apr 3, 2014 at 3:36 PM, Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br>


> Author: ruiu<br>
> Date: Thu Apr  3 17:36:55 2014<br>
> New Revision: 205576<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=205576&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=205576&view=rev</a><br>
> Log:<br>
> Replace a recursion with a loop for speed.<br>
><br>
> Modified:<br>
>     lld/trunk/lib/Core/SymbolTable.cpp<br>
><br>
> Modified: lld/trunk/lib/Core/SymbolTable.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=205576&r1=205575&r2=205576&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=205576&r1=205575&r2=205576&view=diff</a><br>


> ==============================================================================<br>
> --- lld/trunk/lib/Core/SymbolTable.cpp (original)<br>
> +++ lld/trunk/lib/Core/SymbolTable.cpp Thu Apr  3 17:36:55 2014<br>
> @@ -379,11 +379,13 @@ void SymbolTable::addReplacement(const A<br>
>  }<br>
><br>
>  const Atom *SymbolTable::replacement(const Atom *atom) {<br>
> -  AtomToAtom::iterator pos = _replacedAtoms.find(atom);<br>
> -  if (pos == _replacedAtoms.end())<br>
> -    return atom;<br>
> -  // might be chain, recurse to end<br>
> -  return replacement(pos->second);<br>
> +  for (;;) {<br>
> +    AtomToAtom::iterator pos = _replacedAtoms.find(atom);<br>
> +    if (pos == _replacedAtoms.end())<br>
> +      return atom;<br>
> +    // might be chain, recurse to end<br>
<br>
</div></div>Not sure if you want to update this comment now that the algorithm<br>
isn't stack recursive ("recurse" might still be the most suitable way<br>
to describe this algorithm, I don't know)</blockquote><div><br></div><div>Thanks. Updated the comment in r205579.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div class=""><div class="h5">
> +    atom = pos->second;<br>
> +  }<br>
>  }<br>
><br>
>  unsigned int SymbolTable::size() {<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>