mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-19 06:31:18 +00:00
Use setStream infomatted_raw_ostream's constructor, to reduce code
duplication. Also, make setStream honor the old DeleteStream flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76075 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3724b48258
commit
6d53f55291
@ -77,15 +77,8 @@ namespace llvm
|
|||||||
/// underneath it.
|
/// underneath it.
|
||||||
///
|
///
|
||||||
formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
|
formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
|
||||||
: raw_ostream(), TheStream(&Stream), DeleteStream(Delete), Column(0) {
|
: raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {
|
||||||
// This formatted_raw_ostream inherits from raw_ostream, so it'll do its
|
setStream(Stream, Delete);
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
explicit formatted_raw_ostream()
|
explicit formatted_raw_ostream()
|
||||||
: raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {}
|
: raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {}
|
||||||
@ -96,10 +89,16 @@ namespace llvm
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setStream(raw_ostream &Stream, bool Delete = false) {
|
void setStream(raw_ostream &Stream, bool Delete = false) {
|
||||||
|
if (DeleteStream)
|
||||||
|
delete TheStream;
|
||||||
|
|
||||||
TheStream = &Stream;
|
TheStream = &Stream;
|
||||||
DeleteStream = Delete;
|
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();
|
TheStream->flush();
|
||||||
if (size_t BufferSize = TheStream->GetNumBytesInBuffer())
|
if (size_t BufferSize = TheStream->GetNumBytesInBuffer())
|
||||||
SetBufferSize(BufferSize);
|
SetBufferSize(BufferSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user