[Interest] why does Qt prefer to return QList over QVector?

Felix morack felixover at gmail.com
Tue Jan 27 09:54:46 CET 2015


yes, in fact especially then, probably due to caching.

2015-01-27 9:47 GMT+01:00 Daniel França <daniel.franca at gmail.com>:

> is QVector faster even for sequential access?
> On Tue 27 Jan 2015 at 09:42 Mark Gaiser <markg85 at gmail.com> wrote:
>
>> On Tue, Jan 27, 2015 at 8:56 AM, Felix morack <felixover at gmail.com>
>> wrote:
>>
>>> hello,
>>>
>>>
>>> i recently gained a small, but considerable performance boost by
>>> switching out QList for QVector in some legacy code. This is hindered by
>>> the fact that Qt itself often returns QList, eg with QMap::values().
>>>
>>>
>>> Is there a reason for this? Why arent QVectors used?
>>>
>>>
>>> A somewhat related question, why is there no QList::reserve()? I guess i
>>> see how that function might not make much sense from an algorithmic pov,
>>> but shouldnt it at least be there as a NoOp to make it easy switching
>>> between data structures?
>>>
>>>
>>> best regards,
>>>
>>> As far as i know this is for historic reasons. QList used to be faster
>> then QVector (someone, please correct me if i'm wrong) in the old days, but
>> nowadays (Qt5 era) they prefer QVector over QList. It is as fast or faster
>> then QList in nearly every situation. I vaguely remember there being one
>> exception where QList was faster, but i don't know the exception anymore.
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150127/41a199fd/attachment.html>


More information about the Interest mailing list