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

Yaron Keren yaron.keren at gmail.com
Fri Nov 21 14:04:31 PST 2014


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. 

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.

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

http://reviews.llvm.org/D6336






More information about the llvm-commits mailing list