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
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 @@
 }
 
 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(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 @@
   }
   OutBufCur += Size;
 
-  if (Unbuffered)
-    flush();
   return *this;
 }