mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-13 06:25:02 +00:00
Switch Twine::str() to use toVector(), which is now efficient.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79437 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5d598aaf3d
commit
b7be0e8afc
@ -8,27 +8,17 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
std::string Twine::str() const {
|
std::string Twine::str() const {
|
||||||
// FIXME: This should probably use the toVector implementation, once that is
|
SmallString<256> Vec;
|
||||||
// efficient.
|
toVector(Vec);
|
||||||
std::string Res;
|
return std::string(Vec.begin(), Vec.end());
|
||||||
raw_string_ostream OS(Res);
|
|
||||||
print(OS);
|
|
||||||
OS.flush();
|
|
||||||
return Res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Twine::toVector(SmallVectorImpl<char> &Out) const {
|
void Twine::toVector(SmallVectorImpl<char> &Out) const {
|
||||||
// FIXME: This is very inefficient, since we are creating a large raw_ostream
|
|
||||||
// buffer -- hitting malloc, which we were supposed to avoid -- all when we
|
|
||||||
// have this pretty little small vector available.
|
|
||||||
//
|
|
||||||
// The best way to fix this is to make raw_svector_ostream do the right thing
|
|
||||||
// and be efficient, by augmenting the base raw_ostream with the ability to
|
|
||||||
// have the buffer managed by a concrete implementation.
|
|
||||||
raw_svector_ostream OS(Out);
|
raw_svector_ostream OS(Out);
|
||||||
print(OS);
|
print(OS);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user