mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
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:
parent
dedebed468
commit
2a612e12ce
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue