[PATCH] D110369: Support: Skip buffering buffer_unique_ostream's owned stream
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 23 15:05:58 PDT 2021
dexonsmith created this revision.
Herald added a subscriber: mgorny.
dexonsmith requested review of this revision.
Herald added a project: LLVM.
Change buffer_unique_ostream's constructor to call
raw_ostream::SetUnbuffered() on its owned stream. Otherwise,
buffer_unique_ostream's destructor could cause the owned stream to
temporarily allocate a buffer only to be immediately flushed.
Also add some tests for buffer_ostream and buffer_unique_ostream. Use
the same naming scheme as other raw_ostream-related tests (e.g.,
`raw_ostreamTest` for the fixture, `raw_ostream_test.cpp` for the
filename).
(I considered changing buffer_ostream in the same way (calling
SetUnbuffered on the referenced stream), but that seemed like overreach
since the client may have more things to write.)
(I considered merging buffer_ostream and buffer_unique_ostream into a
single class (with a `raw_ostream&` and a `std::unique_ptr` that is only
sometimes used), but that makes the class bigger and the small amount of
code deduplication seems uncompelling.)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110369
Files:
llvm/include/llvm/Support/raw_ostream.h
llvm/unittests/Support/CMakeLists.txt
llvm/unittests/Support/buffer_ostream_test.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110369.374677.patch
Type: text/x-patch
Size: 3599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210923/4e83bac5/attachment.bin>
More information about the llvm-commits
mailing list