Expensive QString = ""

Oswald Buddenhagen kde-optimize@mail.kde.org
Wed, 12 Mar 2003 02:06:51 +0100


On Wed, Mar 12, 2003 at 01:18:18AM +0100, Alexander Kellett wrote:
> On Wed, Mar 12, 2003 at 01:02:25AM +0100, Andr? W?bbeking wrote:
> > I don't know, if QString = "" appears frequently in time critical code (KHtml, 
> > KDE start up, KConfig, ...), but if you really need an empty QString the 
> > better solution would be to use a static const QString like QString::null.
> 
> just fyi,
> (QString::null).isNull() != QString("").isNull())
> therefore, they can't just be randomly switched over.
> in fact i kind of dislike the use of a null string
> in place of an formally empty string, its just not 
> explicit enough for my liking.
> 
yep. that's why we need QString::empty (or something). i cc'd a mail
about this to ettrich, but got no response so far.

i had a lengthly discussion with the trolls trying to convince them to
stop treating null strings as zero-length strings and start treating
them like null pointers (that is, to represent an exceptional state and
never make a valid "extraction" operation on a non-null string return a
null string. QString::QString should be equivalent to 
QString::QString(""), probably).
another approach they are considering is abandoning null strings at all
(the STL way, basically), but i think that would be relatively stupid.
everybody who thinks that i'm right should bug the trolls. the others
should stay quiet. ;)=

greetings

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.