[PATCH] make SmallString::str() return std::string

David Blaikie dblaikie at gmail.com
Fri Nov 21 14:11:25 PST 2014


On Fri, Nov 21, 2014 at 2:04 PM, Yaron Keren <yaron.keren at gmail.com> wrote:

> Hi David,
>
> I have looked into using a single StringRef for std::string, StringRef and
> SmallString. This is easily done but three problems emerge:
>
> 1 We lose efficient in .str(). It does not know to return a pointer to
> std::string even if the twine actually stores a single StringRef to the
> std::string data. A Twine-accepting funciton called with std::string input
> and then calls Twine::str() on its input will result in deep copy of the
> std::string.
>

We could leave the std::string special case.


> 2. The prinout routine printOneChildRepr() output would be less
> informative than today, we no longer have the information about the
> original data type for std::string and SmallString nor their actual
> address, just their data and size.
>
> 3 The Twine could be twice as large.
>

'spose it would. Not sure that's important.


>
> I'm not sure it's worthwhile going this way compared with adding another
> pointer to SmallString member union, what do you think?
>

Yeah, probably no big deal.


>
> http://reviews.llvm.org/D6336
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141121/83cc4548/attachment.html>


More information about the llvm-commits mailing list