[PATCH] KURL optimizations

Roger Larsson kde-optimize@mail.kde.org
Fri, 10 Jan 2003 02:38:13 +0100


On Friday 10 January 2003 00:55, Waldo Bastian wrote:
> Maks, can you run this patch through your benchmark and see what it does?
>=20
> Cheers,
> Waldo

Please don't. :-)

+// WARNING
+// This function CHANGES the argument even though it is const!!!
+static const QString &QString_lower(const QString &s)
+{
+    uint l =3D s.length();
+    QChar *u =3D const_cast<QChar *>(s.unicode());
+    for(;l--;u++)
+       *u =3D u->lower();
+    return s;
+}

Why is its argument (and result) const anyway?
All uses creates the QString before call.
I am not sure that this part is worth it...
Instead try to avoid all uses of QChar pointers.
(or rather if the .lower is so expensive shouldn't you avoid
=2Eunicode too? It looks like you do it twice...
 const QChar* buf =3D _url.unicode();
and in the function above.)

/RogerL

=2D-=20
Roger Larsson
Skellefte=E5
Sweden