From edc66f3ab000f54e0e03c5840d7b54e9bf8615cb Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 19 Nov 2008 07:41:27 +0000 Subject: [PATCH] Use smallstring instead of new[]'ing a string. This simplifies the code and speeds it up. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59604 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseObjc.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index f323d9fe23..9d4d6fb248 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -203,15 +203,11 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration( /// 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: