small string optimization?

Lubos Lunak kde-optimize@mail.kde.org
Tue, 21 Jan 2003 14:22:10 +0100


On Tuesday 21 of January 2003 03:22, Steve Hutton wrote:
> I haven't looked at the QString code to see if
> they are already doing this.  If not, perhaps
> the small string optimization recently adopted by
> many std::string implemenations might improve
> performance?
>
> http://tinyurl.com/4om6

 I think you can forget the first ShortSize == sizeof(char*) case, as that's 
only two QChar's, and I'd expect that to be very rare. Using ShortSize up to 
52  (=64-sizeof(QStringData)+sizeof(char*)), which is 13 QChar's, might 
increase performance (64=usually max. size malloc() tries to allocate faster 
using bins), using larger size probably won't help. And I think you won't be 
able to reuse the QChar*unicode pointer, because of inlining and keeping 
binary compatibility, so that makes max. ShortSize only 48.

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