diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-22 21:16:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-22 21:16:10 +0000 |
commit | 5c5842066bb2b2fb5cccd8cc21537f811256df3d (patch) | |
tree | 1b43cda3d711d8e314879474e0450d87bc97e2d2 /lib/Support/raw_ostream.cpp | |
parent | f1fc9678c548a6b97655cd99f91543c8a2d84e3d (diff) | |
download | external_llvm-5c5842066bb2b2fb5cccd8cc21537f811256df3d.zip external_llvm-5c5842066bb2b2fb5cccd8cc21537f811256df3d.tar.gz external_llvm-5c5842066bb2b2fb5cccd8cc21537f811256df3d.tar.bz2 |
Changes to fix buffering that I forgot to commit with previous patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94222 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/raw_ostream.cpp')
-rw-r--r-- | lib/Support/raw_ostream.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 7cd16c8..10d7ec0 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -562,11 +562,14 @@ raw_svector_ostream::~raw_svector_ostream() { flush(); } -/// clear - Flush the stream and clear the underlying vector. -void raw_svector_ostream::clear() { - if (GetNumBytesInBuffer() == 0) flush(); - - OS.clear(); +/// resync - This is called when the SmallVector we're appending to is changed +/// outside of the raw_svector_ostream's control. It is only safe to do this +/// if the raw_svector_ostream has previously been flushed. +void raw_svector_ostream::resync() { + assert(GetNumBytesInBuffer() == 0 && "Didn't flush before mutating vector"); + + if (OS.capacity() - OS.size() < 64) + OS.reserve(OS.capacity() * 2); SetBuffer(OS.end(), OS.capacity() - OS.size()); } |