[cfe-commits] r59604 - /cfe/trunk/lib/Parse/ParseObjc.cpp
Chris Lattner
sabre at nondot.org
Tue Nov 18 23:41:27 PST 2008
Author: lattner
Date: Wed Nov 19 01:41:27 2008
New Revision: 59604
URL: http://llvm.org/viewvc/llvm-project?rev=59604&view=rev
Log:
Use smallstring instead of new[]'ing a string. This simplifies
the code and speeds it up.
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=59604&r1=59603&r2=59604&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Wed Nov 19 01:41:27 2008
@@ -203,15 +203,11 @@
/// has been capitalized.
static IdentifierInfo *constructSetterName(IdentifierTable &Idents,
const IdentifierInfo *Name) {
- unsigned N = Name->getLength();
- char *SelectorName = new char[3 + N];
- memcpy(SelectorName, "set", 3);
- memcpy(&SelectorName[3], Name->getName(), N);
+ llvm::SmallString<100> SelectorName;
+ SelectorName += "set";
+ SelectorName.append(Name->getName(), Name->getName()+Name->getLength());
SelectorName[3] = toupper(SelectorName[3]);
-
- IdentifierInfo *Setter = &Idents.get(SelectorName, &SelectorName[3 + N]);
- delete[] SelectorName;
- return Setter;
+ return &Idents.get(&SelectorName[0], &SelectorName[SelectorName.size()]);
}
/// objc-interface-decl-list:
More information about the cfe-commits
mailing list