[Development] Important recent changes in QList/QString/QByteArray

Andrei Golubev andrei.golubev at qt.io
Thu Sep 10 15:57:40 CEST 2020

The "flag" is basically "a call to reserve was made"? How do I clear the flag?
shrink_to_fit()/squeeze() do this along the way.

Best Regards,
From: Ville Voutilainen <ville.voutilainen at gmail.com>
Sent: Thursday, September 10, 2020 4:38 PM
To: Andrei Golubev <andrei.golubev at qt.io>
Cc: development at qt-project.org <development at qt-project.org>
Subject: Re: [Development] Important recent changes in QList/QString/QByteArray

On Thu, 10 Sep 2020 at 16:04, Andrei Golubev <andrei.golubev at qt.io> wrote:
> Should I expect to do a reserve call with a *smaller* value than my
> current size is before removing elements from
> a container, in order to set a "target size"? For any standard
> container, such a reserve is a complete noop because
> it can't be responded to by shrinking a capacity lower than the size,
> but with QList it apparently records a preferred size?
> No. If the value passed to reserve is smaller than capacity, we do not shrink*.
> For any passed value, we set a specific flag that the capacity is reserved. There is no notion of "target size" and "target capacity" is out of scope of the container (this is something that the user knows about).
> Instead, having the flag in place, we can decide whether allocation should take place or not. When allocation is not obligatory and the capacity reservation flag is set, we do not reallocate but instead do "something else": in case of erase - just remove elements, in case of prepend - move data around (if necessary).
> The flag is a mere part of QCC's state.

The "flag" is basically "a call to reserve was made"? How do I clear the flag?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200910/f8bc67c3/attachment-0001.html>

More information about the Development mailing list