comments on KDE performance tips
Roger Larsson
kde-optimize@mail.kde.org
Sat, 18 Jan 2003 02:58:01 +0100
On Saturday 18 January 2003 02:47, David Faure wrote:
> On Saturday 18 January 2003 02:16, Roger Larsson wrote:
> > const QString hallo =3D "hallo"; // constructor with copy
> > if (hallo =3D=3D hallo) ... // only compares the string storage locat=
ion
>=20
> Nope. This calls QString::operator=3D=3D, which compares the contents.
> Please don't confuse QString and e.g. char *.
>=20
Use the source! (from qstring.cpp)
bool operator=3D=3D( const QString &s1, const QString &s2 )
{
if ( s1.unicode() =3D=3D s2.unicode() ) <=3D HERE!
return TRUE;
return (s1.length() =3D=3D s2.length()) && s1.isNull() =3D=3D s2.isNul=
l() &&
(memcmp((char*)s1.unicode(),(char*)s2.unicode(),
s1.length()*sizeof(QChar)) =3D=3D 0 );
}
This is the sequence:
a) string locations: same? return true;
b) string length: different? return false
c) isNull: different? return false
d) compare the contents
/RogerL
=2D-=20
Roger Larsson
Skellefte=E5
Sweden