From: Benjamin Kramer Date: Fri, 14 Oct 2011 18:45:16 +0000 (+0000) Subject: Simplify code to avoid a useless string copy. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b5cfbc0b074ef77ccac407533d27778ace4028c;p=clang Simplify code to avoid a useless string copy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141970 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 5ae4dfe83c..39a9ef788f 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -156,12 +156,10 @@ StringRef CGDebugInfo::getObjCMethodName(const ObjCMethodDecl *OMD) { /// getSelectorName - Return selector name. This is used for debugging /// info. StringRef CGDebugInfo::getSelectorName(Selector S) { - llvm::SmallString<256> SName; - llvm::raw_svector_ostream OS(SName); - OS << S.getAsString(); - char *StrPtr = DebugInfoNames.Allocate(OS.tell()); - memcpy(StrPtr, SName.begin(), OS.tell()); - return StringRef(StrPtr, OS.tell()); + const std::string &SName = S.getAsString(); + char *StrPtr = DebugInfoNames.Allocate(SName.size()); + memcpy(StrPtr, SName.data(), SName.size()); + return StringRef(StrPtr, SName.size()); } /// getClassName - Get class name including template argument list.