<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 7, 2017 at 10:51 AM Rafael Espindola via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Thu Dec 7 10:51:19 2017<br>
New Revision: 320070<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=320070&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=320070&view=rev</a><br>
Log:<br>
Simplify .gnu.hash writing. NFC.<br>
<br>
Modified:<br>
lld/trunk/ELF/SyntheticSections.cpp<br>
<br>
Modified: lld/trunk/ELF/SyntheticSections.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=320070&r1=320069&r2=320070&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=320070&r1=320069&r2=320070&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/SyntheticSections.cpp (original)<br>
+++ lld/trunk/ELF/SyntheticSections.cpp Thu Dec 7 10:51:19 2017<br>
@@ -1750,15 +1750,12 @@ void GnuHashTableSection::writeHashTable<br>
// Write hash buckets. Hash buckets contain indices in the following<br>
// hash value table.<br>
uint32_t *Buckets = reinterpret_cast<uint32_t *>(Buf);<br>
- auto SymI = Symbols.begin();<br>
- for (size_t I = 0; I < NBuckets; ++I) {<br>
- auto NewI = std::find_if(SymI, Symbols.end(), [=](const Entry &Ent) {<br>
- return Ent.BucketIdx == I;<br>
- });<br>
- if (NewI != Symbols.end()) {<br>
- write32(Buckets + I, NewI->Sym->DynsymIndex);<br>
- SymI = NewI;<br>
- }<br>
+ uint32_t OldBucket = -1;<br>
+ for (auto I = Symbols.begin(), E = Symbols.end(); I != E; ++I) {<br></blockquote><div><br></div><div>Any particular reason this isn't a range-based for loop?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ if (I->BucketIdx == OldBucket)<br>
+ continue;<br>
+ OldBucket = I->BucketIdx;<br>
+ write32(Buckets + OldBucket, I->Sym->DynsymIndex);<br>
}<br>
<br>
// Write a hash value table. It represents a sequence of chains that<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></div></div>