Replace QList by QVector if the elements are larger than a pointer

If the elements are larger than a pointer, QList does not store the
elements themselves, but pointers to them in a contiguous block of
memory. This wastes quite a bit of memory. This can be prevented easily
by using QVector instead.

REVIEW: 111304
This commit is contained in:
Frank Reininghaus 2013-06-30 14:26:24 +02:00
parent dedebed468
commit 2a612e12ce
3 changed files with 6 additions and 5 deletions

View file

@ -55,8 +55,8 @@ void KItemListSizeHintResolver::itemsInserted(int index, int count)
void KItemListSizeHintResolver::itemsRemoved(int index, int count)
{
const QList<QSizeF>::iterator begin = m_sizeHintCache.begin() + index;
const QList<QSizeF>::iterator end = begin + count;
const QVector<QSizeF>::iterator begin = m_sizeHintCache.begin() + index;
const QVector<QSizeF>::iterator end = begin + count;
m_sizeHintCache.erase(begin, end);
}

View file

@ -23,8 +23,8 @@
#include <libdolphin_export.h>
#include <QByteArray>
#include <QList>
#include <QSizeF>
#include <QVector>
class KItemListView;
@ -47,7 +47,7 @@ public:
private:
const KItemListView* m_itemListView;
mutable QList<QSizeF> m_sizeHintCache;
mutable QVector<QSizeF> m_sizeHintCache;
};
#endif

View file

@ -26,6 +26,7 @@
#include <QRectF>
#include <QSet>
#include <QSizeF>
#include <QVector>
class KItemModelBase;
class KItemListSizeHintResolver;
@ -230,7 +231,7 @@ private:
int column;
int row;
};
QList<ItemInfo> m_itemInfos;
QVector<ItemInfo> m_itemInfos;
friend class KItemListControllerTest;
};