Add a GetBufferSize() member to raw_ostream and use it to
authorDan Gohman <gohman@apple.com>
Wed, 12 Aug 2009 20:52:45 +0000 (20:52 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 12 Aug 2009 20:52:45 +0000 (20:52 +0000)
simplify some formatted_raw_ostream code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78836 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/FormattedStream.h
include/llvm/Support/raw_ostream.h

index 8d6dca6654108b980490198f849972d0b225d037..11a0e18db4ce68ef1aac3e88696cd62d485ce095 100644 (file)
@@ -116,8 +116,7 @@ namespace llvm
       // own buffering, and it doesn't need or want TheStream to do another
       // layer of buffering underneath. Resize the buffer to what TheStream
       // had been using, and tell TheStream not to do its own buffering.
-      TheStream->flush();
-      if (size_t BufferSize = TheStream->GetNumBytesInBuffer())
+      if (size_t BufferSize = TheStream->GetBufferSize())
         SetBufferSize(BufferSize);
       TheStream->SetUnbuffered();
 
index 09ee03098f49df0de07594f64250f25e018c55f9..5f6578fcb505e649c39077a77436667f1c7d2ce8 100644 (file)
@@ -106,6 +106,10 @@ public:
     Unbuffered = false;
   }
 
+  size_t GetBufferSize() const {
+    return OutBufEnd - OutBufStart;
+  }
+
   /// SetUnbuffered - Set the streams buffering status. When
   /// unbuffered the stream will flush after every write. This routine
   /// will also flush the buffer immediately when the stream is being