diff options
-rw-r--r-- | src/gui/image/qxpmhandler.cpp | 14 | ||||
-rw-r--r-- | src/gui/painting/qcolor.cpp | 9 | ||||
-rw-r--r-- | tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp | 24 |
3 files changed, 14 insertions, 33 deletions
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 1a68a819c7..e9ac4a9cc2 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1129,14 +1129,14 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const while (c != colorMap.end()) { QRgb color = c.key(); if (image.format() != QImage::Format_RGB32 && !qAlpha(color)) - line.sprintf("\"%s c None\"", - xpm_color_name(cpp, *c)); + line = QString::asprintf("\"%s c None\"", + xpm_color_name(cpp, *c)); else - line.sprintf("\"%s c #%02x%02x%02x\"", - xpm_color_name(cpp, *c), - qRed(color), - qGreen(color), - qBlue(color)); + line = QString::asprintf("\"%s c #%02x%02x%02x\"", + xpm_color_name(cpp, *c), + qRed(color), + qGreen(color), + qBlue(color)); ++c; s << ',' << endl << line; } diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 7a5a5ec528..945b150375 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -505,16 +505,13 @@ QString QColor::name() const QString QColor::name(NameFormat format) const { - QString s; switch (format) { case HexRgb: - s.sprintf("#%02x%02x%02x", red(), green(), blue()); - break; + return QString::asprintf("#%02x%02x%02x", red(), green(), blue()); case HexArgb: - s.sprintf("#%02x%02x%02x%02x", alpha(), red(), green(), blue()); - break; + return QString::asprintf("#%02x%02x%02x%02x", alpha(), red(), green(), blue()); } - return s; + return QString(); } /*! diff --git a/tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp index e458fc1c80..dd903ab8a1 100644 --- a/tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp @@ -87,11 +87,7 @@ void tst_QPixmapCache::insert() if (cacheType) { QBENCHMARK { for (int i = 0 ; i <= 10000 ; i++) - { - QString tmp; - tmp.sprintf("my-key-%d", i); - QPixmapCache::insert(tmp, p); - } + QPixmapCache::insert(QString::asprintf("my-key-%d", i), p); } } else { QBENCHMARK { @@ -114,12 +110,8 @@ void tst_QPixmapCache::find() QPixmap p; if (cacheType) { QBENCHMARK { - QString tmp; for (int i = 0 ; i <= 10000 ; i++) - { - tmp.sprintf("my-key-%d", i); - QPixmapCache::find(tmp, p); - } + QPixmapCache::find(QString::asprintf("my-key-%d", i), p); } } else { QBENCHMARK { @@ -165,18 +157,10 @@ void tst_QPixmapCache::styleUseCaseComplexKey() if (cacheType) { QBENCHMARK { for (int i = 0 ; i <= 10000 ; i++) - { - QString tmp; - tmp.sprintf("%s-%d-%d-%d-%d-%d-%d", QString("my-progressbar-%1").arg(i).toLatin1().constData(), 5, 3, 0, 358, 100, 200); - QPixmapCache::insert(tmp, p); - } + QPixmapCache::insert(QString::asprintf("%s-%d-%d-%d-%d-%d-%d", QString("my-progressbar-%1").arg(i).toLatin1().constData(), 5, 3, 0, 358, 100, 200), p); for (int i = 0 ; i <= 10000 ; i++) - { - QString tmp; - tmp.sprintf("%s-%d-%d-%d-%d-%d-%d", QString("my-progressbar-%1").arg(i).toLatin1().constData(), 5, 3, 0, 358, 100, 200); - QPixmapCache::find(tmp, p); - } + QPixmapCache::find(QString::asprintf("%s-%d-%d-%d-%d-%d-%d", QString("my-progressbar-%1").arg(i).toLatin1().constData(), 5, 3, 0, 358, 100, 200), p); } } else { QHash<styleStruct, QPixmapCache::Key> hash; |