<div dir="ltr">Ah, I remembered seeing your changes to DenseMap, but missed the ones to StringMap.<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 25, 2016 at 11:55 AM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi Don,</div><div><br></div><div>You may want to look at the series of changes I committed to StringMap and DenseMap.</div><div><br></div><div>The StringMapImpl constructor looks like this now:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#3495af">StringMapImpl</span>::StringMapImpl(<span style="color:#0433ff">unsigned</span> InitSize, <span style="color:#0433ff">unsigned</span> itemSize) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:#3495af">ItemSize</span> = itemSize;</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"> <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,143,0)"><span style="color:#000000"> </span>// If a size is specified, initialize the table with that many buckets.</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:#0433ff">if</span> (InitSize) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,143,0)"><span style="color:#000000"> </span>// The table will grow when the number of entries reach 3/4 of the number of</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,143,0)"><span style="color:#000000"> </span>// buckets. To guarantee that "InitSize" number of entries can be inserted</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,143,0)"><span style="color:#000000"> </span>// in the table without growing, we allocate just what is needed here.</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175)"><span style="color:#000000"> </span>init<span style="color:#000000">(</span>getMinBucketToReserveForEntries<span style="color:#000000">(InitSize));</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(4,51,255)"><span style="color:#000000"> </span>return<span style="color:#000000">;</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div></div><div><br></div><div>I hope this address your concern.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div></font></span><div><div class="h5"><div><br></div><div><br></div><div><blockquote type="cite"><div>On Mar 25, 2016, at 7:39 AM, don hinton <<a href="mailto:hintonda@gmail.com" target="_blank">hintonda@gmail.com</a>> wrote:</div><br><div><p dir="ltr">Won't this still force a rehash since the table will be more that 3/4 full? Assuming the initialization list contains unique keys.</p>
<div class="gmail_quote">On Mar 25, 2016 10:11 AM, "David Blaikie via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Worth a test?</p>
<div class="gmail_quote">On Mar 24, 2016 11:02 PM, "Mehdi Amini via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mehdi_amini<br>
Date: Fri Mar 25 00:57:47 2016<br>
New Revision: 264383<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264383&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=264383&view=rev</a><br>
Log:<br>
StringMap: reserve appropriate size when initializing from an initializer list<br>
<br>
From: Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>><br>
<br>
Modified:<br>
llvm/trunk/include/llvm/ADT/StringMap.h<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/StringMap.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=264383&r1=264382&r2=264383&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=264383&r1=264382&r2=264383&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/StringMap.h Fri Mar 25 00:57:47 2016<br>
@@ -233,7 +233,7 @@ public:<br>
Allocator(A) {}<br>
<br>
StringMap(std::initializer_list<std::pair<StringRef, ValueTy>> List)<br>
- : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {<br>
+ : StringMapImpl(List.size(), static_cast<unsigned>(sizeof(MapEntryTy))) {<br>
for (const auto &P : List) {<br>
insert(P);<br>
}<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>
<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>
<br></blockquote></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div>