From 260f24228b663e27a5f307c994ea6bb38c3f1c38 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 19 Apr 2014 15:11:18 +0200 Subject: QRegularExpression: add ways to force an immediate optimization The fact that we kick in a pattern study and possibly a JIT compilation after an undocumented number of usages is suboptimal, for a number or reasons: users may want to JIT compile a pattern immediately, and at the same time they may not want a random delay in the program (due to the pattern getting optimized at a random usage). So: add an optimize() call to force an immediate pattern optimization, and a pattern option to force an optimization on the first usage. Change-Id: I95efdecfd31f11ca7cceb9c05037df613601a11c Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- src/corelib/tools/qregularexpression.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib/tools/qregularexpression.h') diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h index 5059ea6431..6154ea7c51 100644 --- a/src/corelib/tools/qregularexpression.h +++ b/src/corelib/tools/qregularexpression.h @@ -69,7 +69,8 @@ public: ExtendedPatternSyntaxOption = 0x0008, InvertedGreedinessOption = 0x0010, DontCaptureOption = 0x0020, - UseUnicodePropertiesOption = 0x0040 + UseUnicodePropertiesOption = 0x0040, + OptimizeOnFirstUsageOption = 0x0080 }; Q_DECLARE_FLAGS(PatternOptions, PatternOption) @@ -122,6 +123,8 @@ public: MatchType matchType = NormalMatch, MatchOptions matchOptions = NoMatchOption) const; + void optimize(); + static QString escape(const QString &str); bool operator==(const QRegularExpression &re) const; -- cgit v1.2.3