diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-09-02 10:16:16 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2014-09-02 20:42:51 +0200 |
commit | b04c14429734614fdb7c846a0c319512acee47cd (patch) | |
tree | e8d34f3e359ae1fc644d03c51fcb0aad7f3fe805 /src/gui | |
parent | 1a9992c1f2e44f5a2cb8daffa7bcf5b272d6bec4 (diff) |
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 <allan.jensen@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/opengl/qopenglgradientcache.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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()) |