Add a GetBufferSize() member to raw_ostream and use it to

simplify some formatted_raw_ostream code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78836 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2009-08-12 20:52:45 +00:00
parent 114a266c94
commit f3e488476e
2 changed files with 5 additions and 2 deletions

View 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();

View 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