Commit b9e0da8c authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Optimize ArchiveModel::cleanFileName

Summary: Creating the QRegularExpression is expensive and cleanFileName is called for each entry. By not re-creating the regex we gain a significant archive load time improvement

Test Plan:

Left is before, right is after. Note the red block on the left that isn't present on the right

Reviewers: #ark, elvisangelaccio

Reviewed By: #ark, elvisangelaccio

Subscribers: elvisangelaccio, kde-utils-devel

Tags: #ark

Differential Revision:
parent a97350d6
......@@ -341,12 +341,12 @@ QString ArchiveModel::cleanFileName(const QString& fileName)
// Skip entries with filename "/" or "//" or "."
// "." is present in ISO files.
QRegularExpression pattern(QStringLiteral("/+|\\."));
QRegularExpressionMatch match;
if (fileName.contains(pattern, &match) && match.captured() == fileName) {
qCDebug(ARK) << "Skipping entry with filename" << fileName;
if (fileName == QStringLiteral("/") || fileName == QStringLiteral("//") || fileName == QStringLiteral(".")) {
return QString();
} else if (fileName.startsWith(QLatin1String("./"))) {
if (fileName.startsWith(QLatin1String("./"))) {
return fileName.mid(2);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment