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. https://codereview.qt-project.org/32090 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
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
