> The LXR browser is great, but leaves me a bit puzzled.  Searching for
> nsString (as an identifier) in lxr.mozilla.org/seamonkey, I find the class
> definition in mozilla/string/obsolete/nsString2.h.
> 
> So, why is it referred to as "obsolete"?  What's the status on strings?


I don't know about the status. The owner of string is been 
[EMAIL PROTECTED] but I haven't seem him around (in bugs and newsgroups) 
for a while. The string classes seem pretty stable too.

The obsolete part is about the implementation. The common belief is that 
the implementation should be replaced by a templetized and iterator 
based string class. For the interface I believe it will mostly stay the 
same and the main string classes will continue to be nsString and 
nsAutoString.

Since a web browser handles strings so much and is dependant on 
efficient processing of them, several other string classes (such as 
nsDependantString) has emerged. All these have a common base class, 
nsAString (ns Abstract String). There is also a nsAFlatString that is a 
base class for strings that are guaranteed to be stored in a flat array.

As I have understood the use, you create an nsString if you want a 
string yourself, but if you take a string as a parameter to a function 
you should consider accepting nsAString and nsAFlatString to allow other 
implementations to be passed in. That will probably continue to be true 
after a new nsString is born outside the obsolete directory.

/Daniel


Reply via email to