<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 Jan 2, 2015, at 2:19 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; line-height: 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; line-height: 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 Wed, Dec 31, 2014 at 10:14 PM, Michael Gottesman<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:mgottesman@apple.com" target="_blank" class="">mgottesman@apple.com</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;"><div style="word-wrap: break-word;" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Dec 31, 2014, at 6:47 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><br class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 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; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">On Wed, Dec 31, 2014 at 3:33 PM, Michael Gottesman<span class=""> </span><span dir="ltr" class=""><<a href="mailto:mgottesman@apple.com" target="_blank" class="">mgottesman@apple.com</a>></span><span class=""> </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;">Author: mgottesman<br class="">Date: Wed Dec 31 17:33:24 2014<br class="">New Revision: 225055<br class=""><br class="">URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project?rev=225055&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=225055&view=rev</a><br class="">Log:<br class="">Add 2x constructors for TinyPtrVector, one that takes in one elemenet and the other that takes in an ArrayRef<EltTy><br class=""><br class="">Currently one can only construct an empty TinyPtrVector. These are just missing<br class="">elements of the API.<br class=""><br class="">Modified:<br class=""> <span class=""> </span>llvm/trunk/include/llvm/ADT/TinyPtrVector.h<br class=""> <span class=""> </span>llvm/trunk/unittests/ADT/TinyPtrVectorTest.cpp<br class=""><br class="">Modified: llvm/trunk/include/llvm/ADT/TinyPtrVector.h<br class="">URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/TinyPtrVector.h?rev=225055&r1=225054&r2=225055&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/TinyPtrVector.h?rev=225055&r1=225054&r2=225055&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/include/llvm/ADT/TinyPtrVector.h (original)<br class="">+++ llvm/trunk/include/llvm/ADT/TinyPtrVector.h Wed Dec 31 17:33:24 2014<br class="">@@ -96,6 +96,13 @@ public:<br class=""> return *this;<br class=""> }<br class=""><br class="">+ /// Constructor from a single element.<br class="">+ explicit TinyPtrVector(EltTy Elt) : Val(Elt) {}<br class=""></blockquote><div class=""><br class="">Do you need this one? ArrayRef<T> is already implicitly constructible from a single T, so the other ctor you added should suffice for this case.<br class=""><br class="">(that said, it's not uncommon that too many user-defined conversions fire and these sort of intermediate conversions are needed - so if that's what you've hit, that's cool)<br class=""></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">That is not the reason that I did this.</div><div class=""><br class=""></div><div class="">The reason I did this was from the perspective of API completeness when one is looking and exploring the class. I can imagine a user who is not familiar with ArrayRef’s constructors wondering where this constructor is given the raison d’être of the class. That being said I am not attached to it and I am willing to remove it.</div></div></div></blockquote><div class=""><br class="">If the test pass without I'd suggest removing it (& if the tests don't pass when you remove it, I'd be curious to understand why). We're pretty pervasively using the single-arg ArrayRef ctor, so I doubt it'd take too long for a new developer to discover the idiom & become familiar with it.<br class=""></div></div></div></blockquote><div><br class=""></div><div>Sorry for the delay (r226424). As a bonus I hide the data inside TinyPtrVector. There is no good reason for that to be public.</div><div><br class=""></div><div>Michael</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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;"><div class=""><br class="">- David<br class=""> </div><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;"><div style="word-wrap: break-word;" class=""><div class=""><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">Michael</div></font></span><div class=""><div class="h5"><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class=""><br class="">- David<br class=""> </div><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;">+<br class="">+ /// Constructor from an ArrayRef.<br class="">+ explicit TinyPtrVector(ArrayRef<EltTy> Elts)<br class="">+ : Val(new VecTy(Elts.begin(), Elts.end())) {}<br class="">+<br class=""> // implicit conversion operator to ArrayRef.<br class=""> operator ArrayRef<EltTy>() const {<br class=""> if (Val.isNull())<br class=""><br class="">Modified: llvm/trunk/unittests/ADT/TinyPtrVectorTest.cpp<br class="">URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TinyPtrVectorTest.cpp?rev=225055&r1=225054&r2=225055&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TinyPtrVectorTest.cpp?rev=225055&r1=225054&r2=225055&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/unittests/ADT/TinyPtrVectorTest.cpp (original)<br class="">+++ llvm/trunk/unittests/ADT/TinyPtrVectorTest.cpp Wed Dec 31 17:33:24 2014<br class="">@@ -412,3 +412,29 @@ TYPED_TEST(TinyPtrVectorTest, InsertRang<br class=""> }<br class=""><br class=""> }<br class="">+<br class="">+TEST(TinyPtrVectorTest, SingleEltCtorTest) {<br class="">+ int v = 55;<br class="">+ TinyPtrVector<int *> V(&v);<br class="">+<br class="">+ EXPECT_TRUE(V.size() == 1);<br class="">+ EXPECT_FALSE(V.empty());<br class="">+ EXPECT_TRUE(V.front() == &v);<br class="">+}<br class="">+<br class="">+TEST(TinyPtrVectorTest, ArrayRefCtorTest) {<br class="">+ int data_array[128];<br class="">+ std::vector<int *> data;<br class="">+<br class="">+ for (unsigned i = 0, e = 128; i != e; ++i) {<br class="">+ data_array[i] = 324 - int(i);<br class="">+ data.push_back(&data_array[i]);<br class="">+ }<br class="">+<br class="">+ TinyPtrVector<int *> V(data);<br class="">+ EXPECT_TRUE(V.size() == 128);<br class="">+ EXPECT_FALSE(V.empty());<br class="">+ for (unsigned i = 0, e = 128; i != e; ++i) {<br class="">+ EXPECT_TRUE(V[i] == data[i]);<br class="">+ }<br class="">+}<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="">llvm-commits@cs.uiuc.edu</a><br class=""><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></blockquote></div></div></blockquote></div></div></div></div></blockquote></div></div></blockquote></div><br class=""></body></html>