[KDE] QString optimization using a Proxy class called QStringTemp

Lubos Lunak l.lunak at suse.cz
Fri Apr 23 10:42:27 CEST 2004


On Thursday 22 of April 2004 00:28, Fred P. wrote:
> For more information see:
> http://kde-apps.org/content/show.php?content=12158&forumexplevel=2
>
> It should work on Qt2, Qt3 or higher, need small modification on QString
> class:
>
> - QString(int buffer_length, bool dummy);
> is currently private, you have to change it to public or protected.
>
> - You also have to put ~QString to be a virtual function.

 A bit strange requirement for something like QString. Why exactly, just 
because of a printf() ?

>
> ===============
>
> Improve speed performance of QString
> while keeping the syntax readable as is.
>
> e.g.
> QStringTemp tmp( 4096 );
> QString s = tmp + a + b + c + d;
>
> OR
>
> uint sz = a::length() + b::length() + c::length() + d::length();
> QStringTemp tmp( sz );
> QString s = tmp + a + b + c + d;
>
> Another way is to modify the
> QString::operator+
> to use QStringTemp implicitely.
>
> Performance increase from few ms to 4x faster depending on the buffer size
> and the size of each string.
>
> See test cases screenshots
> for various buffer size algorithms.

 Do you have any more real-world examples? Concatenating thousands of 6000 
chars long strings is probably not a very common scenario, and in cases where 
performance of this could matter there's IMHO not a big difference between 
explicitly using QStringTemp and QString::operator+=.

>
> The Qt version of this code may be released under the GPL/QPL, if needed.

 That's not sufficient for Qt actually, all code for Qt needs to have 
copyright assigned to TrollTech (because of the commercial versions).

 Also, that 400+k archive is not the best way how to distribute one 6k .h file 
and 2k readme file. Distribute it either as your files + diff or just a diff 
(something like diff -u -p -d -N -r dir.old dir.new > dir.patch).

-- 
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o.  e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/


More information about the Kde-optimize mailing list