mirror of
https://github.com/ModOrganizer2/modorganizer-uibase.git
synced 2026-07-27 14:03:49 -07:00
Avoid repeated QRegularExpression compilation (#169)
Co-authored-by: RJ <Liderate@users.noreply.github.com>
This commit is contained in:
+7
-3
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user