[cfe-commits] r65022 - /cfe/trunk/lib/Parse/AttributeList.cpp

Chris Lattner sabre at nondot.org
Wed Feb 18 22:25:12 PST 2009


Author: lattner
Date: Thu Feb 19 00:25:12 2009
New Revision: 65022

URL: http://llvm.org/viewvc/llvm-project?rev=65022&view=rev
Log:
don't new[] an empty array when an AttributeList has 
zero expression arguments.  This eliminates 2579 1-byte
mallocs when parsing Cocoa.h.

Modified:
    cfe/trunk/lib/Parse/AttributeList.cpp

Modified: cfe/trunk/lib/Parse/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/AttributeList.cpp?rev=65022&r1=65021&r2=65022&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/AttributeList.cpp (original)
+++ cfe/trunk/lib/Parse/AttributeList.cpp Thu Feb 19 00:25:12 2009
@@ -16,13 +16,17 @@
 
 AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
                              IdentifierInfo *pName, SourceLocation pLoc,
-                             Action::ExprTy **elist, unsigned numargs,
+                             Action::ExprTy **ExprList, unsigned numArgs,
                              AttributeList *n)
   : AttrName(aName), AttrLoc(aLoc), ParmName(pName), ParmLoc(pLoc),
-    NumArgs(numargs), Next(n) {
-  Args = new Action::ExprTy*[numargs];
-  for (unsigned i = 0; i != numargs; ++i)
-    Args[i] = elist[i];
+    NumArgs(numArgs), Next(n) {
+  
+  if (numArgs == 0)
+    Args = 0;
+  else {
+    Args = new Action::ExprTy*[numArgs];
+    memcpy(Args, ExprList, numArgs*sizeof(Args[0]));
+  }
 }
 
 AttributeList::~AttributeList() {





More information about the cfe-commits mailing list