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 <volker.hilsheimer@qt.io>bb10
parent
8cad4c2903
commit
c2bcba93a6
|
|
@ -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<QPixmapCache::Key, QPixmapCacheEntry>::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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue