<div dir="ltr">Thank you for pointing that out. Committed as <span style="color:rgb(0,0,0)">r247168.</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 10, 2015 at 2:46 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Sep 9, 2015 at 10:40 AM, Rui Ueyama via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Wed Sep 9 12:40:51 2015<br>
New Revision: 247165<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=247165&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=247165&view=rev</a><br>
Log:<br>
ELF2: Return early. NFC.<br>
<br>
Modified:<br>
lld/trunk/ELF/Symbols.cpp<br>
<br>
Modified: lld/trunk/ELF/Symbols.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=247165&r1=247164&r2=247165&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=247165&r1=247164&r2=247165&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Symbols.cpp (original)<br>
+++ lld/trunk/ELF/Symbols.cpp Wed Sep 9 12:40:51 2015<br>
@@ -51,27 +51,26 @@ template <class ELFT> int SymbolBody::co<br>
if (L != R)<br>
return -1;<br>
<br>
- if (L.first && L.second) {<br>
- if (isCommon()) {<br>
- if (Other->isCommon()) {<br>
- auto *ThisC = cast<DefinedCommon<ELFT>>(this);<br>
- auto *OtherC = cast<DefinedCommon<ELFT>>(Other);<br>
- typename DefinedCommon<ELFT>::uintX_t MaxAlign =<br>
- std::max(ThisC->MaxAlignment, OtherC->MaxAlignment);<br>
- if (ThisC->Sym.st_size >= OtherC->Sym.st_size) {<br>
- ThisC->MaxAlignment = MaxAlign;<br>
- return 1;<br>
- }<br>
- OtherC->MaxAlignment = MaxAlign;<br>
- return -1;<br>
+ if (!L.first || !L.second)<br>
+ return 1;<br>
+ if (isCommon()) {<br>
+ if (Other->isCommon()) {<br>
+ auto *ThisC = cast<DefinedCommon<ELFT>>(this);<br>
+ auto *OtherC = cast<DefinedCommon<ELFT>>(Other);<br>
+ typename DefinedCommon<ELFT>::uintX_t MaxAlign =<br>
+ std::max(ThisC->MaxAlignment, OtherC->MaxAlignment);<br>
+ if (ThisC->Sym.st_size >= OtherC->Sym.st_size) {<br>
+ ThisC->MaxAlignment = MaxAlign;<br>
+ return 1;<br>
}<br>
+ OtherC->MaxAlignment = MaxAlign;<br>
return -1;<br></blockquote><div><br></div></div></div><div>You could further reduce some nesting by inverting this block ^. Instead of:<br><br>if (Other->isCommon()) {<br> ...<br> return -1;<br>}<br>return -1;<br><br>You could:<br><br>if (!Other->isCommon())|<br> return -1;<br>...<br><br>(alternatively, if you prefer the nesting, you could at least drop the nested return -1, it'll exit the if and immediately return -1 anyway)</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
- if (Other->isCommon())<br>
- return 1;<br>
- return 0;<br>
+ return -1;<br>
}<br>
- return 1;<br>
+ if (Other->isCommon())<br>
+ return 1;<br>
+ return 0;<br></blockquote><div><br></div></span><div>Possibly not more readable, but this could be written as "return Other->isCommon()".</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
<br>
std::unique_ptr<InputFile> Lazy::getMember() {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div>