[Development] Important recent changes in QList/QString/QByteArray
abbapoh at gmail.com
Thu Sep 3 13:34:54 CEST 2020
In the awful world of the standard library we call vector.shrink_to_fit() to ensure that.
Note that while you have your «please free the memory» use-case someone might have the «please do not free memory, I still need it» use-case.
> 3 сент. 2020 г., в 09:40, Jaroslaw Kobus <Jaroslaw.Kobus at qt.io> написал(а):
>> From: Development <development-bounces at qt-project.org> on behalf of Giuseppe D'Angelo via Development <development at qt-project.org>
>> Sent: Wednesday, September 2, 2020 9:37 PM
>> To: Andrei Golubev; development at qt-project.org; Ville Voutilainen
>> Subject: Re: [Development] Important recent changes in QList/QString/QByteArray
>> On 02/09/2020 21:18, Andrei Golubev wrote:
>>> Also not sure whether it is an implementation detail or the behavior
>>> that should always be anticipated.
>> People build performance sensitive code assuming the cost of certain
>> operations -- like, assuming that erasing elements from a vector never
>> reallocates it; and that the only operation that sheds capacity is
>> squeeze(), everything else (incl. clear(), incl. resize(0)) keeps the
>> capacity (*). We should stop backstabbing them...
> People sometimes care about memory consumption, too. If user's object
> contains a vector consisting of exactly one element, he may be surprised
> that it still consumes a place for one million elements, just because one
> minute ago he removed 999.999 items. If he is creating hundreds
> of such objects sequentially, his app may not run at all (however, will perform very well).
> Development mailing list
> Development at qt-project.org <mailto:Development at qt-project.org>
> https://lists.qt-project.org/listinfo/development <https://lists.qt-project.org/listinfo/development>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Development