From c2bcba93a67ed980021304c3bbca5556b4cc3add Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 12 Jun 2023 12:20:34 +0200 Subject: [PATCH] QPixmapCache: simplify remove(QString) The previous code used `cacheKey` as the name of an iterator, which made the code hard to understand. Instead of renaming that to the more idiomatic `it`, use QHash::take() to get an actual `cacheKey` back, and then delegate to QPMCache::remove(QPixmapCache::Key) for the actual removal. Pick-to: 6.6 6.5 6.2 Task-number: QTBUG-112200 Change-Id: I9311c19f12a05cad694702672f17ae19ba339b04 Reviewed-by: Volker Hilsheimer --- src/gui/image/qpixmapcache.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 76fba1eb93..6c62bae69e 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -352,13 +352,8 @@ QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) bool QPMCache::remove(const QString &key) { - auto cacheKey = cacheKeys.constFind(key); - //The key was not in the cache - if (cacheKey == cacheKeys.constEnd()) - return false; - const bool result = QCache::remove(cacheKey.value()); - cacheKeys.erase(cacheKey); - return result; + const auto cacheKey = cacheKeys.take(key); + return cacheKey.isValid() && remove(cacheKey); } bool QPMCache::remove(const QPixmapCache::Key &key)