QImage: optimize convertWithPalette()

The old code got a QMap serialized as a QString and parsed it to
re-create the same map.

Just copy the map.

Change-Id: Ic71b9fa9d822eab53fe37dfb4d76223cd69ac057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Marc Mutz 2020-03-26 10:53:44 +01:00
parent 871e2981dd
commit 5c1446e3fa
3 changed files with 5 additions and 6 deletions

View File

@ -2149,12 +2149,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format,
QImage dest(src.size(), format);
dest.setColorTable(clut);
QString textsKeys = src.text();
const auto textKeyList = textsKeys.splitRef(QLatin1Char('\n'), Qt::SkipEmptyParts);
for (const auto &textKey : textKeyList) {
const auto textKeySplitted = textKey.split(QLatin1String(": "));
dest.setText(textKeySplitted[0].toString(), textKeySplitted[1].toString());
}
QImageData::get(dest)->text = QImageData::get(src)->text;
int h = src.height();
int w = src.width();

View File

@ -385,6 +385,7 @@ private:
friend class QRasterPlatformPixmap;
friend class QBlittablePlatformPixmap;
friend class QPixmapCacheEntry;
friend struct QImageData;
public:
typedef QImageData * DataPtr;

View File

@ -69,6 +69,9 @@ struct Q_GUI_EXPORT QImageData { // internal image data
static QImageData *create(const QSize &size, QImage::Format format);
static QImageData *create(uchar *data, int w, int h, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
static QImageData *get(QImage &img) noexcept { return img.d; }
static const QImageData *get(const QImage &img) noexcept { return img.d; }
QAtomicInt ref;
int width;