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>bb10
parent
1a9992c1f2
commit
b04c144297
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Reference in New Issue