Avoid repeated QRegularExpression compilation (#169)

Co-authored-by: RJ <Liderate@users.noreply.github.com>
This commit is contained in:
RJ
2025-05-30 17:33:11 +02:00
committed by GitHub
co-authored by RJ
parent 57312386fe
commit 1388eb0c4a
+7 -3
View File
@@ -22,6 +22,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <QRegularExpression>
#include <QVersionNumber>
namespace
{
const QRegularExpression VERSION_REGEX("^(\\d+)(\\.(\\d+))?(\\.(\\d+))?(\\.(\\d+))?");
}
namespace MOBase
{
@@ -289,8 +294,7 @@ void VersionInfo::parse(const QString& versionString, VersionScheme scheme,
temp.remove(0, 1);
}
QRegularExpression exp("^(\\d+)(\\.(\\d+))?(\\.(\\d+))?(\\.(\\d+))?");
auto match = exp.match(temp);
auto match = VERSION_REGEX.match(temp);
if (match.hasMatch()) {
m_Major = match.captured(1).toInt();
m_Minor = match.captured(3).toInt();
@@ -310,7 +314,7 @@ void VersionInfo::parse(const QString& versionString, VersionScheme scheme,
m_Scheme = SCHEME_DECIMALMARK;
m_DecimalPositions = (int)match.captured(3).size();
}
temp.remove(exp);
temp.remove(VERSION_REGEX);
} else {
m_Scheme = SCHEME_LITERAL;
}