summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAndreas Kling <andreas.kling@nokia.com>2010-10-07 08:09:23 (GMT)
committerAndreas Kling <andreas.kling@nokia.com>2010-10-08 08:07:26 (GMT)
commit69ae7469eebda30dbf430ca67d193a62969f516c (patch)
treea767a0f7baf7ad538ab879df8bfd6e0bc6272034 /src/gui
parentf3fcb5b2ec2f8a16e93074e68e9f2aa2604b4ac3 (diff)
downloadQt-69ae7469eebda30dbf430ca67d193a62969f516c.zip
Qt-69ae7469eebda30dbf430ca67d193a62969f516c.tar.gz
Qt-69ae7469eebda30dbf430ca67d193a62969f516c.tar.bz2
QGradientCache: Optimize choosing of which gradient to evict from cache
Use iterator arithmetic instead of QMultiHash::keys() to remove a random gradient color table from the cache. Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index dbf7b26..23be51b 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -4960,8 +4960,8 @@ protected:
int size, int opacity) const;
uint *addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
if (cache.size() == maxCacheSize()) {
- int elem_to_remove = qrand() % maxCacheSize();
- cache.remove(cache.keys()[elem_to_remove]); // may remove more than 1, but OK
+ // may remove more than 1, but OK
+ cache.erase(cache.begin() + (qrand() % maxCacheSize()));
}
CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode());
generateGradientColorTable(gradient, cache_entry.buffer, paletteSize(), opacity);