[patch][rfc] Add pwrite to raw_stream

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Apr 8 18:43:00 PDT 2015


On 8 April 2015 at 21:06, Sean Silva <chisophugis at gmail.com> wrote:
>
>
> On Wed, Apr 8, 2015 at 5:35 PM, Rafael EspĂ­ndola
> <rafael.espindola at gmail.com> wrote:
>>
>> On 8 April 2015 at 20:25, Sean Silva <chisophugis at gmail.com> wrote:
>> > It stops being a "stream" when you add the ability to write at a
>> > specified
>> > offset. It's like adding operator+= to something with "outputiterator"
>> > in
>> > the name. Is there a reason that this has to live inside raw_ostream?
>>
>> The object writer has to write to something. It can do it better if
>> that something supports at least pwrite.
>
>
> Well, it's not only that; it just seems to sort of violate the whole idea of
> raw_ostream:
>
> 00035 /// raw_ostream - This class implements an extremely fast bulk output
> stream
> 00036 /// that can *only* output to a stream.  It does not support seeking,
> reopening,
> 00037 /// rewinding, line buffered disciplines etc. It is a simple buffer
> that outputs
> 00038 /// a chunk at a time.
>
>
> I think it would be better to not tie this directly into raw_ostream.

I can update the comment to say that some of the base classes support
pwrite. Note that raw_fd_stream already supports seek.

But there is a practical need for a stream_with_pwrite and it can be
added to the classes we need without violation the *reason* that
comment exists: raw_ostream has to be fast.

Cheers,
Rafael




More information about the llvm-commits mailing list