<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 14, 2016, at 1:34 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Mon, Mar 14, 2016 at 1:31 PM, escha via llvm-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><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 class="">escha added a comment.<br class=""><br class="">Added a test to make sure that resizing is enough to insert N elements without reallocation for a variety of sizes.<br class=""><br class="">I also looked quickly over the uses and none of the uses seem to be already-compensating for this.<br class=""><span class=""><br class=""><br class="">Repository:<br class=""> <span class="Apple-converted-space"> </span>rL LLVM<br class=""><br class=""><a href="http://reviews.llvm.org/D18154" rel="noreferrer" target="_blank" class="">http://reviews.llvm.org/D18154</a><br class=""><br class="">Files:<br class=""> <span class="Apple-converted-space"> </span>include/llvm/ADT/DenseMap.h<br class=""></span> <span class="Apple-converted-space"> </span>unittests/ADT/DenseMapTest.cpp<br class=""><br class="">Index: unittests/ADT/DenseMapTest.cpp<br class="">===================================================================<br class="">--- unittests/ADT/DenseMapTest.cpp<br class="">+++ unittests/ADT/DenseMapTest.cpp<br class="">@@ -339,6 +339,19 @@<br class="">   EXPECT_TRUE(cit == cit2);<br class=""> }<br class=""><br class="">+// Make sure resize actually gives us enough buckets to insert N items<br class="">+// without increasing allocation size.<br class="">+TEST(DenseMapCustomTest, ResizeTest) {<br class="">+  for (unsigned Size = 16; Size < 32; ++Size) {<br class="">+    DenseMap<unsigned, unsigned> Map;<br class="">+    Map.resize(Size);<br class="">+    unsigned MemorySize = Map.getMemorySize();<br class="">+    for (unsigned i = 0; i < Size; ++i)<br class="">+      Map[i] = i;<br class="">+    EXPECT_TRUE(Map.getMemorySize() == MemorySize);<br class=""></blockquote><div class=""><br class=""></div><div class="">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 class=""></div><div>I have to admit this is probably beyond my C++ knowledge/abilities to do!</div><div><br class=""></div><div>— escha</div></body></html>