mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
In Twine::str(), if the Twine stores only a std::string, just return a direct copy of that instead of first copying to a SmallString and converting that to a std::string. Also fix some indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135267 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -14,6 +14,11 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
std::string Twine::str() const {
|
std::string Twine::str() const {
|
||||||
|
// If we're storing only a std::string, just return it.
|
||||||
|
if (LHSKind == StdStringKind && RHSKind == EmptyKind)
|
||||||
|
return *static_cast<const std::string*>(LHS);
|
||||||
|
|
||||||
|
// Otherwise, flatten and copy the contents first.
|
||||||
SmallString<256> Vec;
|
SmallString<256> Vec;
|
||||||
return toStringRef(Vec).str();
|
return toStringRef(Vec).str();
|
||||||
}
|
}
|
||||||
@@ -37,9 +42,9 @@ StringRef Twine::toNullTerminatedStringRef(SmallVectorImpl<char> &Out) const {
|
|||||||
// Already null terminated, yay!
|
// Already null terminated, yay!
|
||||||
return StringRef(static_cast<const char*>(LHS));
|
return StringRef(static_cast<const char*>(LHS));
|
||||||
case StdStringKind: {
|
case StdStringKind: {
|
||||||
const std::string *str = static_cast<const std::string*>(LHS);
|
const std::string *str = static_cast<const std::string*>(LHS);
|
||||||
return StringRef(str->c_str(), str->size());
|
return StringRef(str->c_str(), str->size());
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user