diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-19 06:25:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-19 06:25:12 +0000 |
commit | b5d8416b90995f0afe340c03eb694763cb18e3ce (patch) | |
tree | f0a48de7781fbb3d38a50f45ba13a7e57479e73f /clang/lib/Parse/AttributeList.cpp | |
parent | 0bbcfa6bb9f45780ad988c67a8a19bd78eb35af2 (diff) | |
download | bcm5719-llvm-b5d8416b90995f0afe340c03eb694763cb18e3ce.tar.gz bcm5719-llvm-b5d8416b90995f0afe340c03eb694763cb18e3ce.zip |
don't new[] an empty array when an AttributeList has
zero expression arguments. This eliminates 2579 1-byte
mallocs when parsing Cocoa.h.
llvm-svn: 65022
Diffstat (limited to 'clang/lib/Parse/AttributeList.cpp')
-rw-r--r-- | clang/lib/Parse/AttributeList.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Parse/AttributeList.cpp b/clang/lib/Parse/AttributeList.cpp index 3d9d2b45f78..6b58a001bca 100644 --- a/clang/lib/Parse/AttributeList.cpp +++ b/clang/lib/Parse/AttributeList.cpp @@ -16,13 +16,17 @@ using namespace clang; 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() { |