On 29/12/2013 20:10, 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().
What about this, re-using your example: my_struct *arr = new my_struct[count]; QVector<my_struct> v(count); memcpy(v.data(), arr, sizeof(my_struct)*count); Assuming "my_struct" doesn't contain self-referencing references or virtual table. Regards, -- (o< | Yves Bailly | -o) //\ | Linux Dijon : http://www.coagul.org | //\ \_/ | | \_/` _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
