From 8e5283ad1d9fd8ad029d524c1c70df5e8d0b9eb3 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 3 Dec 2013 18:18:28 +0000 Subject: [PATCH] Avoid buffer copies when a Twine already is a StringRef. llvm-svn: 196301 --- llvm/lib/MC/MCContext.cpp | 3 +-- llvm/lib/Option/ArgList.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 3b45d1670d2c..7e4cdf98eef7 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -157,8 +157,7 @@ MCSymbol *MCContext::CreateSymbol(StringRef Name) { MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) { SmallString<128> NameSV; - Name.toVector(NameSV); - return GetOrCreateSymbol(NameSV.str()); + return GetOrCreateSymbol(Name.toStringRef(NameSV)); } MCSymbol *MCContext::CreateTempSymbol() { diff --git a/llvm/lib/Option/ArgList.cpp b/llvm/lib/Option/ArgList.cpp index 15f7e8bf4b82..fecd23717359 100644 --- a/llvm/lib/Option/ArgList.cpp +++ b/llvm/lib/Option/ArgList.cpp @@ -291,8 +291,7 @@ void ArgList::ClaimAllArgs() const { const char *ArgList::MakeArgString(const Twine &T) const { SmallString<256> Str; - T.toVector(Str); - return MakeArgString(Str.str()); + return MakeArgString(T.toStringRef(Str)); } const char *ArgList::GetOrMakeJoinedArgString(unsigned Index,