Introduce StringBuilder utility around raw_string_ostream
rafael.espindola at gmail.com
Thu Jun 12 06:19:44 PDT 2014
> The buffering avoids a virtual dispatch for each call (potentially each
> character) because raw_ostream is a virtual interface that gets passed into
> streamers which don't know which subclass is in use.
> (I experimented disabling buffering with raw_null_ostream() and even then
> the buffering helps avoid lots of calls to the no-op virtual write_impl()
> function. So it looks like a good design to me.)
Do you know how many of these calls could be avoided by implementing
operotor<< in the derived class too? I.E, how often do we known that
we are streaming to a string?
Having forgot to add some calls to flush myself in the past I agree
that it would be nice to have some API that lets us avoid that. If
that can be done efficiently in the common case with an external
buffer, that is better.
More information about the llvm-commits