[PATCH] Disable buffering for raw_null_ostream()

Rafael Espíndola rafael.espindola at gmail.com
Fri Jul 3 06:18:09 PDT 2015


> Do you expect memcpy to be faster than a virtual call to an empty function?
> From what I can see with a quick measurement on OS X compiled with Release and *no* assertions it does not seem to be the case.

Good point. I forgot the null implementation was special in that way.

>>> Moreover it kept a shared buffer, and made using nulls() not possible
>>> in a multi-threaded environment.
>>
>> Sorry, I really don't see it. By reading the code it looks like we
>> will call SetBuffered,  which will call  SetBufferSize(Size), which
>> will allocate a new buffer.
>
> Sure, the problem is not with the class raw_null_ostream itself, it is really with the function “nulls()” which returns a static object.
> By having it unbuffered, it become immutable and can be shared across threads.

Ah! Thanks.

OK, making it unbuffered LGTM. Like Duncan I have a small preference
for just using the existing bool.

Cheers,
Rafael




More information about the llvm-commits mailing list