Use static QRegularExpression

This commit is contained in:
Jonas Kvinge
2024-08-24 17:23:10 +02:00
parent a2cae06582
commit bc667a6474
31 changed files with 121 additions and 67 deletions

View File

@@ -388,7 +388,8 @@ void Database::ExecSchemaCommandsFromFile(QSqlDatabase &db, const QString &filen
void Database::ExecSchemaCommands(QSqlDatabase &db, const QString &schema, int schema_version, bool in_transaction) {
// Run each command
QStringList commands = schema.split(QRegularExpression(QStringLiteral("; *\n\n")));
static const QRegularExpression regex_split_commands(QStringLiteral("; *\n\n"));
QStringList commands = schema.split(regex_split_commands);
// We don't want this list to reflect possible DB schema changes, so we initialize it before executing any statements.
// If no outer transaction is provided the song tables need to be queried before beginning an inner transaction!

View File

@@ -129,7 +129,7 @@ void LocalRedirectServer::WriteTemplate() const {
QString page_data = QString::fromUtf8(page_file.readAll());
page_file.close();
QRegularExpression tr_regexp(QStringLiteral("tr\\(\"([^\"]+)\"\\)"));
static const QRegularExpression tr_regexp(QStringLiteral("tr\\(\"([^\"]+)\"\\)"));
qint64 offset = 0;
forever {
QRegularExpressionMatch re_match = tr_regexp.match(page_data, offset);