mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-26 09:18:56 +00:00
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
This commit is contained in:
@@ -123,8 +123,13 @@ void raw_ostream::flush_nonempty() {
|
||||
}
|
||||
|
||||
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(unsigned char C) {
|
||||
}
|
||||
|
||||
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 @@ raw_ostream &raw_ostream::write(const char *Ptr, unsigned Size) {
|
||||
}
|
||||
OutBufCur += Size;
|
||||
|
||||
if (Unbuffered)
|
||||
flush();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user