<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">++ is non-trivial on maps, because it skips non-empty or tombstone buckets. As far as the inlining, I would think they’re all getting inlined, as they are all inline methods in StringMap.h<div><br><div><div>On Mar 17, 2014, at 2:18 PM, Pete Cooper <<a href="mailto:peter_cooper@apple.com">peter_cooper@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Mar 17, 2014, at 1:15 PM, Benjamin Kramer <<a href="mailto:benny.kra@gmail.com">benny.kra@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br>On 17.03.2014, at 20:38, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:<br><br><blockquote type="cite"><br>On Mon, Mar 17, 2014 at 12:32 PM, Pete Cooper <<a href="mailto:peter_cooper@apple.com">peter_cooper@apple.com</a>> wrote:<br>I was worried about duplication, but actually that might be cleaner.  I’ll give that a try now.<br><br>If the duplication is a problem, factor that into a private helper function used by both?<br></blockquote><br>It can be written in two lines, not worth its own function.<br></blockquote>Agreed.<br><blockquote type="cite"><br>for (auto &Entry : this)<br>  Entry.Destroy(Allocator);<br></blockquote><div>Thanks for this.  Its a nice small snippet.  I tweaked it to this:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">    <span style="color: #bb2ca2">if</span> (!<span style="color: #31595d">empty</span>()) {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">      <span style="color: #bb2ca2">for</span> (<span style="color: #bb2ca2">auto</span> &Entry : *<span style="color: #bb2ca2">this</span>)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">        Entry.Destroy(<span style="color: #4f8187">Allocator</span>);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">However, this is still about 10% faster</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><div style="margin: 0px; min-height: 13px;"><br></div><div style="margin: 0px;">    <span style="color: #bb2ca2">if</span> (!empty()) {</div><div style="margin: 0px;">      <span style="color: #bb2ca2">for</span> (<span style="color: #bb2ca2">unsigned</span> I = <span style="color: #272ad8">0</span>, E = NumBuckets; I != E; ++I) {</div><div style="margin: 0px;">        StringMapEntryBase *&Bucket = TheTable[I];</div><div style="margin: 0px;">        <span style="color: #bb2ca2">if</span> (Bucket && Bucket != getTombstoneVal()) {</div><div style="margin: 0px;">          <span style="color: #bb2ca2">static_cast</span><MapEntryTy*>(Bucket)->Destroy(Allocator);</div><div style="margin: 0px;">        }</div><div style="margin: 0px;">      }</div><div style="margin: 0px;">    }</div><div style="margin: 0px;"><br></div><div style="margin: 0px;">The problem is that iterator++ isn’t getting optimized out.  Actually neither is the whole loop I gave, but somehow it runs a bit quicker.  I think its failing to inline ++ as it shows up in the trace even on -O3.</div><div style="margin: 0px;"><br></div><div style="margin: 0px;">Pete</div></div></div><blockquote type="cite"><br>- Ben</blockquote></div><br></div>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></blockquote></div><br></div></body></html>