[PATCH] Reports: Convert to C++

Chris Johns chrisj at rtems.org
Fri Jul 9 00:19:58 UTC 2021


On 9/7/21 3:06 am, Alex White wrote:
> On Wed, Jul 7, 2021 at 6:55 PM Chris Johns <chrisj at rtems.org> wrote:
>>
>> On 7/7/21 11:37 pm, Ryan Long wrote:
>> > I'll get those pointers changed to references, and remove the whitespace changes. Is there a particular reason to not use '\n' instead of std::endl?
>>
>> Awesome and thanks.
>>
>> > I read that std::endl is slower since it's flushing the buffer each time that it is used.
>>
>> The std::endl is platform independent so language implementers can match it to
>> the platform the code is being built for. It is similar to os.linesep in python
>> and why that should be used there.
> 
> Chris,
> 
> I thought this, too, until Ryan forced me to look into it further. Thanks, Ryan :)
> 
> According to various sources, '\n' gets translated to the current platform's
> line separator as long as the C++ file stream is opened in text mode. See, for
> example, https://stackoverflow.com/a/213977 <https://stackoverflow.com/a/213977>.

Why would you use std::endl in a binary stream? Is the report a binary format?

> So |std::endl|​ would indeed likely be slower AND unnecessary to achieve
> platform independence.

Some platforms require '\r\n' for an end of line. How does this approach handle
that?

Have you measured the performance savings this provides?

I prefer you do not add special code for that sort of stuff and I prefer we
avoid micro-optimisations over following the standards based ways of handling
these things.

Chris


More information about the devel mailing list