<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 3, 2015 at 3:44 PM, Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: davide<br>
Date: Tue Feb  3 17:44:33 2015<br>
New Revision: 228069<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=228069&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=228069&view=rev</a><br>
Log:<br>
Avoid two function calls of file() when not needed.<br>
<br>
Reported by:    ruiu<br>
<br>
Modified:<br>
    lld/trunk/lib/Core/DefinedAtom.cpp<br>
<br>
Modified: lld/trunk/lib/Core/DefinedAtom.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/DefinedAtom.cpp?rev=228069&r1=228068&r2=228069&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/DefinedAtom.cpp?rev=228069&r1=228068&r2=228069&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Core/DefinedAtom.cpp (original)<br>
+++ lld/trunk/lib/Core/DefinedAtom.cpp Tue Feb  3 17:44:33 2015<br>
@@ -83,12 +83,15 @@ DefinedAtom::ContentPermissions DefinedA<br>
<br>
 bool DefinedAtom::compareByPosition(const DefinedAtom *lhs,<br>
                                     const DefinedAtom *rhs) {<br>
-  const File *lhsFile = &lhs->file();<br>
-  const File *rhsFile = &rhs->file();<br>
+  const File *lhsFile;<br>
+  const File *rhsFile;<br>
<br>
   if (lhs == rhs)<br>
     return false;<br>
<br>
+  lhsFile = &lhs->file();<br>
+  rhsFile = &rhs->file();<br>
+<br>
   if (lhsFile->ordinal() != rhsFile->ordinal())<br>
     return lhsFile->ordinal() < rhsFile->ordinal();<br>
   assert(lhs->ordinal() != rhs->ordinal());<br></blockquote><div><br></div><div>Oh, the new code looks like too C89-ish. You could have intermingled declarations and code like this. It's better to do pre-commit code review, perhaps?</div><div><br></div><div>if (lhs == rhs)</div><div>  return false;</div><div>const File *lhsFile = &lhs->file();</div><div>const File *rhsFile = &rhs->file();</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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>
</blockquote></div><br></div></div>