Skip to content

Commit a9c14ab

Browse files
committed
PERF: Don't create temporary QRegularExpression
warning: Don't create temporary QRegularExpression objects. Use a static QRegularExpression object instead [-Wclazy-use-static-qregularexpression] Is alerting that the same QRegularExpression object is re-created every time a function is called or expression is evaluated. This is inefficient, especially for repeated use, because QRegularExpression has a non-trivial construction cost (it compiles the regex pattern). auto match = re.match(content);
1 parent f1df0ec commit a9c14ab

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

generator/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ namespace
223223

224224
unsigned int getQtVersion(const QString &commandLineIncludes, const QString &qtIncludPrefix = {})
225225
{
226-
QRegularExpression re("#define\\s+QTCORE_VERSION\\s+0x([0-9a-f]+)", QRegularExpression::CaseInsensitiveOption);
226+
static const QRegularExpression re("#define\\s+QTCORE_VERSION\\s+0x([0-9a-f]+)",
227+
QRegularExpression::CaseInsensitiveOption);
227228
for (const QString &includeDir: getIncludeDirectories(commandLineIncludes, qtIncludPrefix))
228229
{
229230
QFileInfo fi(QDir(includeDir), "qtcoreversion.h");

0 commit comments

Comments
 (0)