[LLVMdev] SmallString + raw_svector_ostream combination should be more efficient

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Apr 20 06:26:54 PDT 2015


> To solve all three issues, would it make sense to have raw_ostream-derived
> container with a its own SmallString like templated-size built-in buffer?

It can be improved. I am not sure templating the stream itself is the
best option.

I think it is possible to implement a derived class that duplicates
nothing and is not templated.

* The constructor gets passed a buffer (pointer, size) and can handle (null, 0).
* It sets up the base class to write past the existing data, like
raw_svector_ostream does.
* When more data is needed, allocate a new buffer, copy data from the
old one, and update the base class pointers.

A user can then pass a stack allocated buffer to get something like a
raw_svector_ostream. It could pass a null to get a convenient class
that handles all allocations.

Cheers,
Rafael



More information about the llvm-dev mailing list