[llvm-commits] [llvm] r120984 - in /llvm/trunk/include/llvm/ADT: SmallString.h SmallVector.h

Chris Lattner clattner at apple.com
Mon Dec 6 13:03:30 PST 2010


On Dec 5, 2010, at 9:44 PM, Michael Spencer wrote:

>> I don't think this makes sense, why not just cast data?  With wchar_t you usually need a multibyte 0 anyway.
>> 
>> -Chris
> 
> c_str() as implemented uses push_back to add the 0, thus we get a
> sizeof(wchar_t) byte null terminator. The reason this is needed is
> because I kept running into bugs trying to keep track of when I needed
> to add a null terminator. This way I can use c_str() exactly when
> passing the string to a Windows API function.

Oh right, but why add this to SmallVector?  It doesn't seem to make sense there.  If there are weird clients that want this in the system library, can't they either take a smallstring, or just do push_back(0) + pop_back() manually?

-Chris



More information about the llvm-commits mailing list