<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 17, 2016 at 10:17 AM, David Blaikie via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, May 16, 2016 at 3:53 PM, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Mon May 16 17:53:19 2016<br>
New Revision: 269717<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=269717&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=269717&view=rev</a><br>
Log:<br>
Switch from SmallVector to TinyPtrVector for the list of attributes on a declaration. This removes a memory allocation for the common case where the declaration has only one attribute.<br></blockquote><div><br></div></span><div>Just out of curiosity - if the SmallVector had a small size of 2, why was an allocation done for a single attribute?</div></div></div></div></blockquote><div><br></div><div>Err, good question. Turns out I forgot to make the actual allocation-saving change here -- switching ASTContext::DeclAttrs from storing an allocated AttrVec* to storing an AttrVec. And that in turn is quite painful because we expose the AttrVec object to people who might cause DeclAttrs to be resized. I'll see if it's practical to finish this change, and revert if not.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Modified:<br>
    cfe/trunk/include/clang/AST/AttrIterator.h<br>
<br>
Modified: cfe/trunk/include/clang/AST/AttrIterator.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/AttrIterator.h?rev=269717&r1=269716&r2=269717&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/AttrIterator.h?rev=269717&r1=269716&r2=269717&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/AttrIterator.h (original)<br>
+++ cfe/trunk/include/clang/AST/AttrIterator.h Mon May 16 17:53:19 2016<br>
@@ -15,6 +15,7 @@<br>
 #define LLVM_CLANG_AST_ATTRITERATOR_H<br>
<br>
 #include "clang/Basic/LLVM.h"<br>
+#include "llvm/ADT/TinyPtrVector.h"<br>
 #include <iterator><br>
<br>
 namespace clang {<br>
@@ -39,8 +40,8 @@ void operator delete[](void *Ptr, const<br>
 namespace clang {<br>
<br>
 /// AttrVec - A vector of Attr, which is how they are stored on the AST.<br>
-typedef SmallVector<Attr*, 2> AttrVec;<br>
-typedef SmallVector<const Attr*, 2> ConstAttrVec;<br>
+typedef llvm::TinyPtrVector<Attr*> AttrVec;<br>
+typedef llvm::TinyPtrVector<const Attr*> ConstAttrVec;<br>
<br>
 /// specific_attr_iterator - Iterates over a subrange of an AttrVec, only<br>
 /// providing attributes that are of a specific type.<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>