QIcon: don't use a QList<QImage>

QImage is larger than a void*, so holding them in a QList is needlessly
inefficient.

Use QVector instead.

Change-Id: Ifcc9eca18a87e29327586506e3a3bb7874c8b3a7
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
Marc Mutz 2014-08-16 13:03:38 +02:00
parent 3e6f36175a
commit 9e6a61447c

View File

@ -362,7 +362,7 @@ static inline int origIcoDepth(const QImage &image)
return s.isEmpty() ? 32 : s.toInt(); return s.isEmpty() ? 32 : s.toInt();
} }
static inline int findBySize(const QList<QImage> &images, const QSize &size) static inline int findBySize(const QVector<QImage> &images, const QSize &size)
{ {
for (int i = 0; i < images.size(); ++i) { for (int i = 0; i < images.size(); ++i) {
if (images.at(i).size() == size) if (images.at(i).size() == size)
@ -426,7 +426,7 @@ void QPixmapIconEngine::addFile(const QString &fileName, const QSize &size, QIco
// these files may contain low-resolution images. As this information is lost, // these files may contain low-resolution images. As this information is lost,
// ICOReader sets the original format as an image text key value. Read all matching // ICOReader sets the original format as an image text key value. Read all matching
// images into a list trying to find the highest quality per size. // images into a list trying to find the highest quality per size.
QList<QImage> icoImages; QVector<QImage> icoImages;
while (imageReader.read(&image)) { while (imageReader.read(&image)) {
if (ignoreSize || image.size() == size) { if (ignoreSize || image.size() == size) {
const int position = findBySize(icoImages, image.size()); const int position = findBySize(icoImages, image.size());