diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-04-13 18:00:37 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-04-13 18:00:37 +0000 |
commit | c6b468e46d467eb8d0bcfdbbcc776ef9650133a0 (patch) | |
tree | 06e1b6baa7f6ffcf27d532d55b29c09bb5bbaf01 | |
parent | b8896146703a2206782337efa1d391447e6b383e (diff) |
Avoid string thrashing when we can concatenate them in the final buffer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154678 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 7301d2060b..d286d24715 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -184,7 +184,6 @@ CGDebugInfo::getClassName(const RecordDecl *RD) { const TemplateArgument *Args; unsigned NumArgs; - std::string Buffer; if (TypeSourceInfo *TAW = Spec->getTypeAsWritten()) { const TemplateSpecializationType *TST = cast<TemplateSpecializationType>(TAW->getType()); @@ -195,16 +194,17 @@ CGDebugInfo::getClassName(const RecordDecl *RD) { Args = TemplateArgs.data(); NumArgs = TemplateArgs.size(); } - Buffer = RD->getIdentifier()->getNameStart(); + StringRef Name = RD->getIdentifier()->getName(); PrintingPolicy Policy(CGM.getLangOpts()); - Buffer += TemplateSpecializationType::PrintTemplateArgumentList(Args, - NumArgs, - Policy); + std::string TemplateArgList = + TemplateSpecializationType::PrintTemplateArgumentList(Args, NumArgs, Policy); // Copy this name on the side and use its reference. - char *StrPtr = DebugInfoNames.Allocate<char>(Buffer.length()); - memcpy(StrPtr, Buffer.data(), Buffer.length()); - return StringRef(StrPtr, Buffer.length()); + size_t Length = Name.size() + TemplateArgList.size(); + char *StrPtr = DebugInfoNames.Allocate<char>(Length); + memcpy(StrPtr, Name.data(), Name.size()); + memcpy(StrPtr + Name.size(), TemplateArgList.data(), TemplateArgList.size()); + return StringRef(StrPtr, Length); } /// getOrCreateFile - Get the file debug info descriptor for the input location. |