llvm.org GIT mirror llvm / cc1c702
Don't allow formatted_ostream to be unbuffered, even if its underlying buffer is. - The problem is that formatted_ostream forces its underlying buffer to be unbuffered, so if some client happens to wrap a formatted_ostream around something, but still use the underlying stream, then we can end up writing on a fully unbuffered output (which was never intended to be unbuffered). - This makes clang (and presumably llvm-gcc) -emit-llvm -S a mere 10x faster. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82434 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
1 changed file(s) with 6 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
104104 // own buffering, and it doesn't need or want TheStream to do another
105105 // layer of buffering underneath. Resize the buffer to what TheStream
106106 // had been using, and tell TheStream not to do its own buffering.
107 //
108 // If the underlying stream is unbuffered, just use its preferred buffer
109 // size. We can't treat this as an honest wish for unbuffered output,
110 // because it could very well be a stream we previously forced to be
111 // unbuffered.
107112 if (size_t BufferSize = TheStream->GetBufferSize())
108113 SetBufferSize(BufferSize);
109114 else
110 SetUnbuffered();
115 SetBuffered();
111116 TheStream->SetUnbuffered();
112117
113118 Scanned = 0;