[Development] OK to add zero/bulk copy to QVector?

Thiago Macieira thiago.macieira at intel.com
Mon Dec 30 02:50:24 CET 2013

On domingo, 29 de dezembro de 2013 21:10:53, Jiergir Ogoerg wrote:
> Hi,
> there are 2 simple options to speed up setting/adding elements to a
> vector when a heap buffer is filled in in advance:
> 1) Bulk copy.
> Assign a bunch of elements at once (from another vector or array),
> like std::vector::assign() does.
> A big extra copy happens, but avoids multiple calls to push_back().

This might be a good idea. Copying with iterators, for example. Even though 
it's not much different than reserve() and append() each element, it has one 
distinct advantage: it updates the vector count only once. Updating it each 
and every time is a possible bottleneck. At least, that's the discussion in 
the std-proposals mailing list...

> 2) Zero copy.
> Set the buffer of the (Q)Vector directly along with the number of
> elements to bypass any copying whatsoever, std::vector lacks this
> apparently.


That's Qt 6 material. You can't implement fromRawData in Qt 5.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131229/fda613f2/attachment.sig>

More information about the Development mailing list