Option 2 is faster than option 1.
Momergil (29th May 2014)
You should probably also benchmark using an explicit memcpy from the source array to the target array.
Cheers,
_
Yeah, for my particular situation that inspired me to do this question, I'ld say memcpy is not allowed (the vector is a vector of double, and the array is an array of short). But in any case, how could I do a memcpy from an array to a QVector if their types were compatible? memcpy(&myVector,myArray,sizeof(myArray)) doesn't seem that would work.
May the Lord be with you. Always.
You can safely copy doubles from one vector to another using memcpy. You cannot copy classes that have non-trivial constructors. memcpy() accepts addresses where it should copy to/from.
Qt Code:
memcpy(myVector.data(), myArray, length_of_array);To copy to clipboard, switch view to plain text mode
Momergil (30th May 2014)
Bookmarks