QRegularExpression: lock a mutex only if there's actual work to do

We can do the (atomic) test of studyData before locking the mutex
protecting the entire function body.

Change-Id: I3006e3a0028608f21668ddaebe8a799aed56362f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2014-04-26 16:32:06 +02:00 committed by The Qt Project
parent 5b300a1526
commit 007252adb9

View File

@ -1137,11 +1137,11 @@ void QRegularExpressionPrivate::optimizePattern(OptimizePatternOption option)
{
Q_ASSERT(compiledPattern);
QMutexLocker lock(&mutex);
if (studyData.load()) // already optimized
return;
QMutexLocker lock(&mutex);
if ((option == LazyOptimizeOption) && (++usedCount != qt_qregularexpression_optimize_after_use_count))
return;