summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-22 21:16:10 +0000
committerChris Lattner <sabre@nondot.org>2010-01-22 21:16:10 +0000
commit1386a88c95d7fbf6c22a7bdaea0dd706702970a0 (patch)
treef2fa2571a6cfea6735216494552ef82f6bd72128 /llvm/lib/Support/raw_ostream.cpp
parente567c8e67fbd79d7fb2096f74c90f3be72dba95b (diff)
downloadbcm5719-llvm-1386a88c95d7fbf6c22a7bdaea0dd706702970a0.tar.gz
bcm5719-llvm-1386a88c95d7fbf6c22a7bdaea0dd706702970a0.zip
Changes to fix buffering that I forgot to commit with previous patch.
llvm-svn: 94222
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 7cd16c888b9..10d7ec07012 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/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());
}
OpenPOWER on IntegriCloud