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

@@ -192,7 +192,10 @@ OrganizeFormat::GetFilenameForSongResult OrganizeFormat::GetFilenameForSong(cons
}
filepath = parts_new.join(QLatin1Char('/'));
if (replace_spaces_) filepath.replace(QRegularExpression(QStringLiteral("\\s")), QStringLiteral("_"));
if (replace_spaces_) {
static const QRegularExpression regex_whitespaces(QStringLiteral("\\s"));
filepath.replace(regex_whitespaces, QStringLiteral("_"));
}
if (!extension.isEmpty()) {
filepath.append(QStringLiteral(".%1").arg(extension));
@@ -308,7 +311,8 @@ QString OrganizeFormat::TagValue(const QString &tag, const Song &song) const {
else if (tag == QLatin1String("artistinitial")) {
value = song.effective_albumartist().trimmed();
if (!value.isEmpty()) {
value.replace(QRegularExpression(QStringLiteral("^the\\s+"), QRegularExpression::CaseInsensitiveOption), QLatin1String(""));
static const QRegularExpression regex_the(QStringLiteral("^the\\s+"), QRegularExpression::CaseInsensitiveOption);
value = value.remove(regex_the);
value = value[0].toUpper();
}
}