Use static QRegularExpression
This commit is contained in:
@@ -48,12 +48,13 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
QByteArray data = device->readAll();
|
||||
|
||||
// Some playlists have unescaped & characters in URLs :(
|
||||
QRegularExpression ex(QStringLiteral("(href\\s*=\\s*\")([^\"]+)\""), QRegularExpression::CaseInsensitiveOption);
|
||||
static const QRegularExpression ex(QStringLiteral("(href\\s*=\\s*\")([^\"]+)\""), QRegularExpression::CaseInsensitiveOption);
|
||||
qint64 index = 0;
|
||||
for (QRegularExpressionMatch re_match = ex.match(QString::fromUtf8(data), index); re_match.hasMatch(); re_match = ex.match(QString::fromUtf8(data), index)) {
|
||||
index = re_match.capturedStart();
|
||||
QString url = re_match.captured(2);
|
||||
url.replace(QRegularExpression(QStringLiteral("&(?!amp;|quot;|apos;|lt;|gt;)")), QStringLiteral("&"));
|
||||
static const QRegularExpression regex_html_enities(QStringLiteral("&(?!amp;|quot;|apos;|lt;|gt;)"));
|
||||
url.replace(regex_html_enities, QStringLiteral("&"));
|
||||
|
||||
QByteArray replacement = QStringLiteral("%1%2\"").arg(re_match.captured(1), url).toLocal8Bit();
|
||||
data.replace(re_match.captured(0).toLocal8Bit(), replacement);
|
||||
|
||||
@@ -309,7 +309,9 @@ QStringList CueParser::SplitCueLine(const QString &line) {
|
||||
}
|
||||
|
||||
// Let's remove the empty entries while we're at it
|
||||
return re_match.capturedTexts().filter(QRegularExpression(QStringLiteral(".+"))).mid(1, -1).replaceInStrings(QRegularExpression(QStringLiteral("^\"\"$")), QLatin1String(""));
|
||||
static const QRegularExpression regex_entry(QStringLiteral(".+"));
|
||||
static const QRegularExpression regex_exclude(QStringLiteral("^\"\"$"));
|
||||
return re_match.capturedTexts().filter(regex_entry).mid(1, -1).replaceInStrings(regex_exclude, QLatin1String(""));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
||||
|
||||
QString filename = filename_or_url;
|
||||
|
||||
if (filename_or_url.contains(QRegularExpression(QStringLiteral("^[a-z]{2,}:"), QRegularExpression::CaseInsensitiveOption))) {
|
||||
static const QRegularExpression regex_url_schema(QStringLiteral("^[a-z]{2,}:"), QRegularExpression::CaseInsensitiveOption);
|
||||
if (filename_or_url.contains(regex_url_schema)) {
|
||||
QUrl url(filename_or_url);
|
||||
song->set_source(Song::SourceFromURL(url));
|
||||
if (song->source() == Song::Source::LocalFile) {
|
||||
|
||||
@@ -50,7 +50,7 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
Q_UNUSED(playlist_path);
|
||||
|
||||
QMap<int, Song> songs;
|
||||
QRegularExpression n_re(QStringLiteral("\\d+$"));
|
||||
static const QRegularExpression n_re(QStringLiteral("\\d+$"));
|
||||
|
||||
while (!device->atEnd()) {
|
||||
QString line = QString::fromUtf8(device->readLine()).trimmed();
|
||||
|
||||
Reference in New Issue
Block a user