QString: Allocating more than needed?

David Leimbach kde-optimize@mail.kde.org
Sun, 26 Jan 2003 09:02:52 -0600


On Sunday, January 26, 2003, at 04:27 AM, David Faure wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Sunday 26 January 2003 11:20, Stefan Heimers wrote:
>> - Is there a way to create qstrings with a fixed length, which won't
>> waste memory in case you know they will never grow?
>
> Yes, setLength().
>
>> - It would be nice to have an option to set the maximum expected 
>> length
>> of a qstring, so it won't allocate in excess, or too little if you 
>> know
>> a string will grow considerably.
>
> setLength() ? :)
>
>
Actually there is no guarantee that you only get the length you specify 
in the setLength call.  In fact the docs state you get "at least" that 
many ... so its hard to know if that's exactly how much is reserved or 
not.

http://doc.trolltech.com/3.1/qstring.html#setLength