[llvm-commits] [llvm] r76075 - /llvm/trunk/include/llvm/Support/FormattedStream.h
Dan Gohman
gohman at apple.com
Thu Jul 16 08:37:42 PDT 2009
Author: djg
Date: Thu Jul 16 10:37:26 2009
New Revision: 76075
URL: http://llvm.org/viewvc/llvm-project?rev=76075&view=rev
Log:
Use setStream infomatted_raw_ostream's constructor, to reduce code
duplication. Also, make setStream honor the old DeleteStream flag.
Modified:
llvm/trunk/include/llvm/Support/FormattedStream.h
Modified: llvm/trunk/include/llvm/Support/FormattedStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FormattedStream.h?rev=76075&r1=76074&r2=76075&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FormattedStream.h (original)
+++ llvm/trunk/include/llvm/Support/FormattedStream.h Thu Jul 16 10:37:26 2009
@@ -77,15 +77,8 @@
/// underneath it.
///
formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
- : raw_ostream(), TheStream(&Stream), DeleteStream(Delete), Column(0) {
- // This formatted_raw_ostream inherits from raw_ostream, so it'll do its
- // 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())
- SetBufferSize(BufferSize);
- TheStream->SetUnbuffered();
+ : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {
+ setStream(Stream, Delete);
}
explicit formatted_raw_ostream()
: raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {}
@@ -96,10 +89,16 @@
}
void setStream(raw_ostream &Stream, bool Delete = false) {
+ if (DeleteStream)
+ delete TheStream;
+
TheStream = &Stream;
DeleteStream = Delete;
- // Avoid double-buffering, as above.
+ // This formatted_raw_ostream inherits from raw_ostream, so it'll do its
+ // 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())
SetBufferSize(BufferSize);
More information about the llvm-commits
mailing list