<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 14, 2016 at 1:40 PM,  <span dir="ltr"><<a href="mailto:escha@apple.com" target="_blank">escha@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><div class="h5"><br><div><blockquote type="cite"><div>On Mar 14, 2016, at 1:34 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><br><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Mon, Mar 14, 2016 at 1:31 PM, escha via llvm-commits<span> </span><span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">escha updated this revision to Diff 50637.<br>escha added a comment.<br><br>Added a test to make sure that resizing is enough to insert N elements without reallocation for a variety of sizes.<br><br>I also looked quickly over the uses and none of the uses seem to be already-compensating for this.<br><span><br><br>Repository:<br> <span> </span>rL LLVM<br><br><a href="http://reviews.llvm.org/D18154" rel="noreferrer" target="_blank">http://reviews.llvm.org/D18154</a><br><br>Files:<br> <span> </span>include/llvm/ADT/DenseMap.h<br></span> <span> </span>unittests/ADT/DenseMapTest.cpp<br><br>Index: unittests/ADT/DenseMapTest.cpp<br>===================================================================<br>--- unittests/ADT/DenseMapTest.cpp<br>+++ unittests/ADT/DenseMapTest.cpp<br>@@ -339,6 +339,19 @@<br>   EXPECT_TRUE(cit == cit2);<br> }<br><br>+// Make sure resize actually gives us enough buckets to insert N items<br>+// without increasing allocation size.<br>+TEST(DenseMapCustomTest, ResizeTest) {<br>+  for (unsigned Size = 16; Size < 32; ++Size) {<br>+    DenseMap<unsigned, unsigned> Map;<br>+    Map.resize(Size);<br>+    unsigned MemorySize = Map.getMemorySize();<br>+    for (unsigned i = 0; i < Size; ++i)<br>+      Map[i] = i;<br>+    EXPECT_TRUE(Map.getMemorySize() == MemorySize);<br></blockquote><div><br></div><div>This is probably sufficient (just checking that the size didn't change) - but in case it's of interest, I was thinking of a unit test with a move-or-copy-counting object in the key or value of the map, then checking no extra moves-or-copies occur.</div></div></div></blockquote><br></div></div></div><div>I have to admit this is probably beyond my C++ knowledge/abilities to do!</div></div></blockquote><div><br></div><div>No worries</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class="HOEnZb"><font color="#888888"><div><br></div><div>— escha</div></font></span></div></blockquote></div><br></div></div>