<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Don,</div><div class=""><br class=""></div><div class="">You may want to look at the series of changes I committed to StringMap and DenseMap.</div><div class=""><br class=""></div><div class="">The StringMapImpl constructor looks like this now:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">StringMapImpl</span>::StringMapImpl(<span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">unsigned</span> InitSize, <span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">unsigned</span> itemSize) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">  <span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">ItemSize</span> = itemSize;</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">  <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">  </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;" class="">  <span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">if</span> (InitSize) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">    </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);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">    </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);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">    </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);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">    </span>init<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>getMinBucketToReserveForEntries<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(InitSize));</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">    </span>return<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">  }</div></div><div class=""><br class=""></div><div class="">I hope this address your concern.</div><div class=""><br class=""></div><div class="">-- </div><div class="">Mehdi</div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Mar 25, 2016, at 7:39 AM, don hinton <<a href="mailto:hintonda@gmail.com" class="">hintonda@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><p dir="ltr" class="">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" class="">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution" class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr" class="">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" class="">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution" class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mehdi_amini<br class="">
Date: Fri Mar 25 00:57:47 2016<br class="">
New Revision: 264383<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264383&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=264383&view=rev</a><br class="">
Log:<br class="">
StringMap: reserve appropriate size when initializing from an initializer list<br class="">
<br class="">
From: Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" target="_blank" class="">mehdi.amini@apple.com</a>><br class="">
<br class="">
Modified:<br class="">
    llvm/trunk/include/llvm/ADT/StringMap.h<br class="">
<br class="">
Modified: llvm/trunk/include/llvm/ADT/StringMap.h<br class="">
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" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=264383&r1=264382&r2=264383&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)<br class="">
+++ llvm/trunk/include/llvm/ADT/StringMap.h Fri Mar 25 00:57:47 2016<br class="">
@@ -233,7 +233,7 @@ public:<br class="">
       Allocator(A) {}<br class="">
<br class="">
   StringMap(std::initializer_list<std::pair<StringRef, ValueTy>> List)<br class="">
-      : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {<br class="">
+      : StringMapImpl(List.size(), static_cast<unsigned>(sizeof(MapEntryTy))) {<br class="">
     for (const auto &P : List) {<br class="">
       insert(P);<br class="">
     }<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div>
<br class="">_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
<br class=""></blockquote></div>
</div></blockquote></div><br class=""></body></html>