mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Introduce Twine::toStringRef, a variant of toVector which avoids the copy if the
twine can be represented as a single StringRef. Use the new methode to simplify some twine users. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93317 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,8 +15,7 @@ using namespace llvm;
|
||||
|
||||
std::string Twine::str() const {
|
||||
SmallString<256> Vec;
|
||||
toVector(Vec);
|
||||
return std::string(Vec.begin(), Vec.end());
|
||||
return toStringRef(Vec).str();
|
||||
}
|
||||
|
||||
void Twine::toVector(SmallVectorImpl<char> &Out) const {
|
||||
@@ -24,6 +23,13 @@ void Twine::toVector(SmallVectorImpl<char> &Out) const {
|
||||
print(OS);
|
||||
}
|
||||
|
||||
StringRef Twine::toStringRef(SmallVectorImpl<char> &Out) const {
|
||||
if (isSingleStringRef())
|
||||
return getSingleStringRef();
|
||||
toVector(Out);
|
||||
return StringRef(Out.data(), Out.size());
|
||||
}
|
||||
|
||||
void Twine::printOneChild(raw_ostream &OS, const void *Ptr,
|
||||
NodeKind Kind) const {
|
||||
switch (Kind) {
|
||||
|
||||
Reference in New Issue
Block a user