Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] QVector vs c++ array - performance
maximus last edited by maximus
I am using a QVector<double> and wondering if there are major performance lost compared to a standard C++ array (double myArray[size])
I am using QVector mainly because I like the use of the convenience functions (.fill, initialization with a value for the whole QVector). I could just create a function for the 2 things above that iterate in the C++ array and set the values. Is there any benefit from switching from QVector to a c++ array except less memory used?
My QVector has a fixed size(40), and I do a lot of .replace() and .at()
The only good answer is: benchmark
Look what fits best to your use case/hardware setup
Is there any benefit from switching from QVector to a c++ array except less memory used?
QVector basically is an array with a couple of convenience methods around it so for most cases there's not gonna be any difference at all.
It's only slightly larger (couple bytes) than a raw array so that's not a big issue either.
maximus last edited by
Thanks SGaist and Chris for confirming this!
Readable code > couple bytes, so I'm sticking with QVector.