Simplify code to avoid a useless string copy.

llvm-svn: 141970
This commit is contained in:
Benjamin Kramer 2011-10-14 18:45:16 +00:00
parent fd0b05f341
commit 47b5b31e61
1 changed files with 4 additions and 6 deletions

View File

@ -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<char>(OS.tell());
memcpy(StrPtr, SName.begin(), OS.tell());
return StringRef(StrPtr, OS.tell());
const std::string &SName = S.getAsString();
char *StrPtr = DebugInfoNames.Allocate<char>(SName.size());
memcpy(StrPtr, SName.data(), SName.size());
return StringRef(StrPtr, SName.size());
}
/// getClassName - Get class name including template argument list.