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:
parent
5b300a1526
commit
007252adb9
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user