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

@@ -112,7 +112,7 @@ QString DecodeHtmlEntities(const QString &text) {
QString ReplaceMessage(const QString &message, const Song &song, const QString &newline, const bool html_escaped) {
QRegularExpression variable_replacer(QStringLiteral("[%][a-z]+[%]"));
static const QRegularExpression variable_replacer(QStringLiteral("[%][a-z]+[%]"));
QString copy(message);
// Replace the first line
@@ -125,7 +125,8 @@ QString ReplaceMessage(const QString &message, const Song &song, const QString &
pos += match.capturedLength();
}
qint64 index_of = copy.indexOf(QRegularExpression(QStringLiteral(" - (>|$)")));
static const QRegularExpression regexp(QStringLiteral(" - (>|$)"));
qint64 index_of = copy.indexOf(regexp);
if (index_of >= 0) copy = copy.remove(index_of, 3);
return copy;