summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2015-11-30 15:26:16 +0100
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2015-12-07 16:56:37 +0000
commit9dde61f4b3519b4de5b83fab463c8d8136baf5b6 (patch)
tree30bda1b66ff5d47b6da3708570e23e317015ad83 /src/gui
parent420b4dbece04f8015cad24a49622c65c540f0a22 (diff)
Optimize qt_findAtNxFile by reducing the amount of allocations
Change-Id: I94a2b40933f9469f509a4cc54d68138696704ba2 Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qicon.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index dc6cbfed1f..d9e1347e4b 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -1400,15 +1401,15 @@ QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRati
if (disableNxImageLoading)
return baseFileName;
- QString atNx = QLatin1String("@%1x");
int dotIndex = baseFileName.lastIndexOf(QLatin1Char('.'));
if (dotIndex == -1) /* no dot */
dotIndex = baseFileName.size(); /* append */
+ QString atNxfileName = baseFileName;
+ atNxfileName.insert(dotIndex, QLatin1String("@2x"));
// Check for @Nx, ..., @3x, @2x file versions,
- for (int n = qCeil(targetDevicePixelRatio); n > 1; --n) {
- QString atNxfileName = baseFileName;
- atNxfileName.insert(dotIndex, atNx.arg(n));
+ for (int n = qMin(qCeil(targetDevicePixelRatio), 9); n > 1; --n) {
+ atNxfileName[dotIndex + 1] = QLatin1Char('0' + n);
if (QFile::exists(atNxfileName)) {
if (sourceDevicePixelRatio)
*sourceDevicePixelRatio = n;