From 1a4a2f7f5826b37843380f3b629ecbaadf45c0f0 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Jul 2018 21:55:48 +0200 Subject: [PATCH] QLogging: make QRegularExpression objects static const To avoid recompiling them multiple times. Change-Id: Ie4766be3bbaa536bf22b0eaacc430055fe4651cd Reviewed-by: Jesus Fernandez --- src/corelib/global/qlogging.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index c9326e7366..308ebe7a68 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1211,8 +1211,8 @@ void QMessagePattern::setPattern(const QString &pattern) tokens[i] = backtraceTokenC; QString backtraceSeparator = QStringLiteral("|"); int backtraceDepth = 5; - QRegularExpression depthRx(QStringLiteral(" depth=(?|\"([^\"]*)\"|([^ }]*))")); - QRegularExpression separatorRx(QStringLiteral(" separator=(?|\"([^\"]*)\"|([^ }]*))")); + static const QRegularExpression depthRx(QStringLiteral(" depth=(?|\"([^\"]*)\"|([^ }]*))")); + static const QRegularExpression separatorRx(QStringLiteral(" separator=(?|\"([^\"]*)\"|([^ }]*))")); QRegularExpressionMatch m = depthRx.match(lexeme); if (m.hasMatch()) { int depth = m.capturedRef(1).toInt(); @@ -1298,7 +1298,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount) // The offset and function name are optional. // This regexp tries to extract the library name (without the path) and the function name. // This code is protected by QMessagePattern::mutex so it is thread safe on all compilers - static QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$")); + static const QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$")); QVarLengthArray buffer(8 + frameCount); int n = backtrace(buffer.data(), buffer.size());