[cfe-commits] r118915 - /cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
Benjamin Kramer
benny.kra at googlemail.com
Fri Nov 12 10:45:23 PST 2010
Author: d0k
Date: Fri Nov 12 12:45:23 2010
New Revision: 118915
URL: http://llvm.org/viewvc/llvm-project?rev=118915&view=rev
Log:
Reduce string thrashing.
Modified:
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=118915&r1=118914&r2=118915&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Fri Nov 12 12:45:23 2010
@@ -371,26 +371,31 @@
const TagDecl *TD = cast<TagType>(Ty).getDecl();
const llvm::Type *Res = ConvertTagDeclType(TD);
- std::string TypeName(TD->getKindName());
- TypeName += '.';
+ llvm::SmallString<256> TypeName;
+ llvm::raw_svector_ostream OS(TypeName);
+ OS << TD->getKindName() << '.';
// Name the codegen type after the typedef name
// if there is no tag type name available
- if (TD->getIdentifier())
+ if (TD->getIdentifier()) {
// FIXME: We should not have to check for a null decl context here.
// Right now we do it because the implicit Obj-C decls don't have one.
- TypeName += TD->getDeclContext() ? TD->getQualifiedNameAsString() :
- TD->getNameAsString();
- else if (const TypedefType *TdT = dyn_cast<TypedefType>(T))
+ if (TD->getDeclContext())
+ OS << TD->getQualifiedNameAsString();
+ else
+ TD->printName(OS);
+ } else if (const TypedefType *TdT = dyn_cast<TypedefType>(T)) {
// FIXME: We should not have to check for a null decl context here.
// Right now we do it because the implicit Obj-C decls don't have one.
- TypeName += TdT->getDecl()->getDeclContext() ?
- TdT->getDecl()->getQualifiedNameAsString() :
- TdT->getDecl()->getNameAsString();
- else
- TypeName += "anon";
+ if (TdT->getDecl()->getDeclContext())
+ OS << TdT->getDecl()->getQualifiedNameAsString();
+ else
+ TdT->getDecl()->printName(OS);
+ } else {
+ OS << "anon";
+ }
- TheModule.addTypeName(TypeName, Res);
+ TheModule.addTypeName(OS.str(), Res);
return Res;
}
More information about the cfe-commits
mailing list