[cfe-commits] r84458 - /cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Daniel Dunbar
daniel at zuster.org
Sun Oct 18 18:21:19 PDT 2009
Author: ddunbar
Date: Sun Oct 18 20:21:19 2009
New Revision: 84458
URL: http://llvm.org/viewvc/llvm-project?rev=84458&view=rev
Log:
Avoid std::string concatenation.
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=84458&r1=84457&r2=84458&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun Oct 18 20:21:19 2009
@@ -850,7 +850,7 @@
/// \param[out] NameOut - The return value.
void GetNameForMethod(const ObjCMethodDecl *OMD,
const ObjCContainerDecl *CD,
- std::string &NameOut);
+ llvm::SmallVectorImpl<char> &NameOut);
/// GetMethodVarName - Return a unique constant for the given
/// selector's name. The return value has type char *.
@@ -2302,7 +2302,7 @@
llvm::Function *CGObjCCommonMac::GenerateMethod(const ObjCMethodDecl *OMD,
const ObjCContainerDecl *CD) {
- std::string Name;
+ llvm::SmallString<256> Name;
GetNameForMethod(OMD, CD, Name);
CodeGenTypes &Types = CGM.getTypes();
@@ -2311,7 +2311,7 @@
llvm::Function *Method =
llvm::Function::Create(MethodTy,
llvm::GlobalValue::InternalLinkage,
- Name,
+ Name.str(),
&CGM.getModule());
MethodDefinitions.insert(std::make_pair(OMD, Method));
@@ -3449,21 +3449,15 @@
void CGObjCCommonMac::GetNameForMethod(const ObjCMethodDecl *D,
const ObjCContainerDecl *CD,
- std::string &NameOut) {
- NameOut = '\01';
- NameOut += (D->isInstanceMethod() ? '-' : '+');
- NameOut += '[';
+ llvm::SmallVectorImpl<char> &Name) {
+ llvm::raw_svector_ostream OS(Name);
assert (CD && "Missing container decl in GetNameForMethod");
- NameOut += CD->getNameAsString();
+ OS << '\01' << (D->isInstanceMethod() ? '-' : '+')
+ << '[' << CD->getName();
if (const ObjCCategoryImplDecl *CID =
- dyn_cast<ObjCCategoryImplDecl>(D->getDeclContext())) {
- NameOut += '(';
- NameOut += CID->getNameAsString();
- NameOut+= ')';
- }
- NameOut += ' ';
- NameOut += D->getSelector().getAsString();
- NameOut += ']';
+ dyn_cast<ObjCCategoryImplDecl>(D->getDeclContext()))
+ OS << '(' << CID->getNameAsString() << ')';
+ OS << ' ' << D->getSelector().getAsString() << ']';
}
void CGObjCMac::FinishModule() {
More information about the cfe-commits
mailing list