diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2014-04-26 16:32:06 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-06 00:11:04 +0200 |
commit | 007252adb9008a05940972a4332bce5d00512570 (patch) | |
tree | 6a531650466877d0ffeaff81c1c6df80f3cacb0a /src/corelib/tools/qregularexpression.cpp | |
parent | 5b300a152699fa1ae833eb38066f3cbd60b61142 (diff) |
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>
Diffstat (limited to 'src/corelib/tools/qregularexpression.cpp')
-rw-r--r-- | src/corelib/tools/qregularexpression.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 316681e652..2cd76b389d 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -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; |