Re: QCString construction
Roger Larsson <[email protected]> Sat, 10 Feb 2007 18:45:33 +0100
| Newsgroups | gmane.comp.kde.devel.optimize |
|---|---|
| Message-ID | <[email protected]> |
On Saturday 10 February 2007 02:16, David Faure wrote: > > One for Qt itself: why does QCString use the slow way when duplicating > QCStrings? (I know that QCString tmp( s1 ); is shallow copy, but the next > line calls operator+= which calls detach) Unless someone spots a flaw in > this patch I'll be posting it to TT (and I'm testing my local kde with it > starting from tomorrow ;) I think it is because all these will require detach, so a new string has to be allocated anyway. But will it be large enough to avoid an extra copy when appending? The tmp constructors could use a hint that they will grow. That could be done in the append anyway... Have you benchmarked that your Qt patch really is faster? /RogerL