diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-19 18:09:47 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-19 18:09:47 +0000 |
commit | b7be0e8afc5378c77c70e3c0fb6a03c74e551688 (patch) | |
tree | 7ff8a1da97e431f1f084e78a31fa7a583e167b6e /lib/Support/Twine.cpp | |
parent | 5d598aaf3de7f506749f4a0a142fe0121854e1a6 (diff) |
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
Diffstat (limited to 'lib/Support/Twine.cpp')
-rw-r--r-- | lib/Support/Twine.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/lib/Support/Twine.cpp b/lib/Support/Twine.cpp index 611af8c5ae..292c0c2b9e 100644 --- a/lib/Support/Twine.cpp +++ b/lib/Support/Twine.cpp @@ -8,27 +8,17 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/Twine.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; std::string Twine::str() const { - // FIXME: This should probably use the toVector implementation, once that is - // efficient. - std::string Res; - raw_string_ostream OS(Res); - print(OS); - OS.flush(); - return Res; + SmallString<256> Vec; + toVector(Vec); + return std::string(Vec.begin(), Vec.end()); } 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); print(OS); } |