From b04c14429734614fdb7c846a0c319512acee47cd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 2 Sep 2014 10:16:16 +0200 Subject: [PATCH] QOpenGL2GradientCache::getBuffer: calculate hash value outside critical section The code doesn't touch any member variables, so it doesn't need mutex protection. Reducing the time spent under the mutex allows a higher speedup (Amdahl's Law), so do it. Also made the mutex locker const to indicate it is never unlock()ed again. Change-Id: Ic50b827c0e34d39cbddc7ec83675b568a9c33f6d Reviewed-by: Allan Sandfeld Jensen --- src/gui/opengl/qopenglgradientcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/opengl/qopenglgradientcache.cpp b/src/gui/opengl/qopenglgradientcache.cpp index 91b4d08474..f8060fc6a0 100644 --- a/src/gui/opengl/qopenglgradientcache.cpp +++ b/src/gui/opengl/qopenglgradientcache.cpp @@ -102,13 +102,13 @@ void QOpenGL2GradientCache::cleanCache() GLuint QOpenGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity) { - QMutexLocker lock(&m_mutex); quint64 hash_val = 0; QGradientStops stops = gradient.stops(); for (int i = 0; i < stops.size() && i <= 2; i++) hash_val += stops[i].second.rgba(); + const QMutexLocker lock(&m_mutex); QOpenGLGradientColorTableHash::const_iterator it = cache.constFind(hash_val); if (it == cache.constEnd())