Commit 45e87e05 authored by Fushan Wen's avatar Fushan Wen
Browse files

wallpapers/image: Port to std::remove_if

This should make `ImageBackend::setSlidePaths` slightly more efficient,
because a lookup operation in the list is gone.
parent 100aa732
Pipeline #164713 passed with stage
in 5 minutes and 51 seconds
......@@ -400,12 +400,13 @@ void ImageBackend::setSlidePaths(const QStringList &slidePaths)
if (!m_slidePaths.isEmpty()) {
// Replace 'preferred://wallpaperlocations' with real paths
const QStringList preProcessedPaths = m_slidePaths;
for (const QString &path : preProcessedPaths) {
if (path == QLatin1String("preferred://wallpaperlocations")) {
m_slidePaths << QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("wallpapers"), QStandardPaths::LocateDirectory);
m_slidePaths.removeAll(path);
}
const auto it = std::remove_if(m_slidePaths.begin(), m_slidePaths.end(), [](const QString &path) {
return path == QLatin1String("preferred://wallpaperlocations");
});
if (it != m_slidePaths.end()) {
m_slidePaths.erase(it, m_slidePaths.end());
m_slidePaths << QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("wallpapers"), QStandardPaths::LocateDirectory);
}
}
......
Supports Markdown
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