Back to index
nsTAString is the most abstract class in the string hierarchy. More...
|typedef nsCharTraits< char_type >||char_traits|
< char_type >
< char_type >
nsTAString is the most abstract class in the string hierarchy.
In its original inception, nsTAString was designed to allow the data storage for a string to be separated into multiple fragments. This was intended to enable lazy string flattening or avoid string flattening altogether in some cases. This abstraction, however, meant that every single string operation (including simple operations such as IsEmpty() and BeginReading()) required virtual function calls. A virtual destructor was also required. This not only meant additional overhead for invoking string methods but also added to additional codesize at every callsite (to load the virtual function address).
Today nsTAString exists mainly for backwards compatibility of the string API. It is restricted to representing a contiguous array of characters, where the character array is not necessarily null-terminated. Moreover, since nsTAString's virtual function table was frozen for Mozilla 1.0, nsTAString necessarily maintains ABI compatibility with older versions of Gecko. (nsTObsoleteAString provides that frozen ABI. See nsObsoleteAString.h for a description of how we solve the ABI compatibility requirement while eliminating virtual function calls on nsTAString.)
XPIDL still generates C++ header files with references to nsTAStrings, so nsTAString will still be heavily used in real code.
If the opportunity to break ABI compatibility with Mozilla 1.0 were to ever arise, our first move should be to make nsTAString equate to nsTSubstring. This may in fact be an option today for some Gecko-based products.
|typedef char_traits::incompatible_char_type nsTAString_CharT::incompatible_char_type|