diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-13 07:12:06 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-13 07:12:06 +0000 |
commit | bf86e5df180139310bf2f0d71bef58e208dce31d (patch) | |
tree | f36f04487db30ccf5c65a3def34030974a43f46f /lib | |
parent | 0e7ab8cb07716305894fabcc512b8d5d0318bd4d (diff) |
add new isSingleStringRef()/getSingleStringRef() methods to twine,
and use them to avoid a copy of a string in getNameWithPrefix in
the common case. It seems like Value::setName and other places
should use this as well?
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93301 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/Mangler.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/VMCore/Mangler.cpp b/lib/VMCore/Mangler.cpp index 87a623a8f9..4d8a91cbf3 100644 --- a/lib/VMCore/Mangler.cpp +++ b/lib/VMCore/Mangler.cpp @@ -188,8 +188,13 @@ std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix, void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName, const Twine &GVName, ManglerPrefixTy PrefixTy) { SmallString<256> TmpData; - GVName.toVector(TmpData); - StringRef Name = TmpData.str(); + StringRef Name; + if (GVName.isSingleStringRef()) + Name = GVName.getSingleStringRef(); + else { + GVName.toVector(TmpData); + Name = TmpData.str(); + } assert(!Name.empty() && "getNameWithPrefix requires non-empty name"); // If the global name is not led with \1, add the appropriate prefixes. |