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

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Thu Sep 10 11:01:39 CEST 2020


Il 10/09/20 04:31, Thiago Macieira ha scritto:
>> This is another against automatic shrinking; it may invalidate
>> everything rather than just the erased area. I don't understand the
>> "detach" part, is it about holding references across a detach, so they
>> refer to the original container, not the detached one? That's not
>> different from we always had, isn't it?
> It means that if you try to erase from a container that is currently shared,
> it will detach. When it does, the detached container's size will be evaluated
> in terms of the size of the container, not the capacity the shared container
> had.
> 

Why isn't the capacity carried across?
> 
> QVector<Foo> v;
> v.reserve(100);
> v.push_back(~~~); // fill it up
> 
> // someone takes a copy
> auto v2 = v;
> 
> // erase into the original
> v.erase(~~~); 
> 
> // now v's capacity is no longer reserved to be >= 100?

My 2 c,

-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200910/fa2aca35/attachment-0001.bin>


More information about the Development mailing list