aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-17 01:13:35 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-17 01:13:35 +0000
commitd17d74bb80d9da1712a066df40122e8584dad227 (patch)
tree52f6ed729f4c3fc9424adad8dad5b1dd81f01809 /lib/Support
parent6b233395025069f63156ea2b524cdb708a14731f (diff)
downloadexternal_llvm-d17d74bb80d9da1712a066df40122e8584dad227.zip
external_llvm-d17d74bb80d9da1712a066df40122e8584dad227.tar.gz
external_llvm-d17d74bb80d9da1712a066df40122e8584dad227.tar.bz2
raw_ostream: Rework implementation of unbuffered streams so outputting
a single character requires only one branch to follow slow path. - Never use a buffer when writing on an unbuffered stream. - Move default buffer size to header. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67066 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/raw_ostream.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 3b33ad6..6aec947 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -123,8 +123,13 @@ void raw_ostream::flush_nonempty() {
}
raw_ostream &raw_ostream::write(unsigned char C) {
+ if (Unbuffered) {
+ write_impl(reinterpret_cast<char*>(&C), 1);
+ return *this;
+ }
+
if (!OutBufStart)
- SetBufferSize(4096);
+ SetBufferSize();
else if (OutBufCur >= OutBufEnd)
flush_nonempty();
@@ -133,8 +138,13 @@ raw_ostream &raw_ostream::write(unsigned char C) {
}
raw_ostream &raw_ostream::write(const char *Ptr, unsigned Size) {
+ if (Unbuffered) {
+ write_impl(Ptr, Size);
+ return *this;
+ }
+
if (!OutBufStart)
- SetBufferSize(4096);
+ SetBufferSize();
else if (OutBufCur+Size > OutBufEnd)
flush_nonempty();
@@ -161,8 +171,6 @@ raw_ostream &raw_ostream::write(const char *Ptr, unsigned Size) {
}
OutBufCur += Size;
- if (Unbuffered)
- flush();
return *this;
}