Commit 82e51845 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

clazy: Ensure for() loops iterate over a constant object, prevent unnecessary copies

parent 3d71e429
......@@ -1451,7 +1451,7 @@ ResultsStream *FlatpakBackend::search(const AbstractResourcesBackend::Filters &f
auto stream = new ResultsStream(QStringLiteral("FlatpakStream-installed"));
auto f = [this, stream, filter] {
QVector<AbstractResource *> resources;
for (auto installation : m_installations) {
for (auto installation : std::as_const(m_installations)) {
g_autoptr(GError) localError = nullptr;
g_autoptr(GPtrArray) refs = flatpak_installation_list_installed_refs(installation, m_cancellable, &localError);
if (!refs) {
......@@ -1504,7 +1504,7 @@ ResultsStream *FlatpakBackend::search(const AbstractResourcesBackend::Filters &f
resources = source->m_resources.values().toVector();
}
for (auto r : resources) {
for (auto r : std::as_const(resources)) {
const bool matchById = r->appstreamId().compare(filter.search, Qt::CaseInsensitive) == 0;
if (r->type() == AbstractResource::Technical && filter.state != AbstractResource::Upgradeable && !matchById) {
continue;
......@@ -1631,7 +1631,7 @@ AbstractReviewsBackend *FlatpakBackend::reviewsBackend() const
void FlatpakBackend::checkRepositories(const QMap<QString, QStringList> &names)
{
auto flatpakInstallationByPath = [this](const QString &path) -> FlatpakInstallation * {
for (auto inst : m_installations) {
for (auto inst : std::as_const(m_installations)) {
if (FlatpakResource::installationPath(inst) == path)
return inst;
}
......@@ -1749,7 +1749,7 @@ Transaction *FlatpakBackend::removeApplication(AbstractResource *app)
void FlatpakBackend::checkForUpdates()
{
for (auto source : qAsConst(m_flatpakSources)) {
for (const auto &source : qAsConst(m_flatpakSources)) {
if (source->remote()) {
Q_ASSERT(!m_refreshAppstreamMetadataJobs.contains(source->remote()));
m_refreshAppstreamMetadataJobs.insert(source->remote());
......
......@@ -233,7 +233,7 @@ void PackageKitBackend::reloadPackageList()
}
for (const AppStream::Component &dc : distroComponents) {
const auto releases = dc.releases();
for (auto r : releases) {
for (const auto &r : releases) {
int cmp = AppStream::Utils::vercmpSimple(r.version(), AppStreamIntegration::global()->osRelease()->versionId());
if (cmp == 0) {
// Ignore (likely) empty date_eol entries that are parsed as the UNIX Epoch
......
......@@ -217,7 +217,8 @@ public:
void setCandidates(const QSet<AbstractResource *> &candidates)
{
for (auto res : (m_resources - candidates)) {
const auto toDisconnect = (m_resources - candidates);
for (auto res : toDisconnect) {
disconnect(res, &AbstractResource::sizeChanged, this, &SystemUpgrade::refreshResource);
}
......@@ -438,7 +439,7 @@ void PackageKitUpdater::finished(PackageKit::Transaction::Exit exit, uint /*time
if (!toremove.isEmpty()) {
QStringList criticals;
for (const auto &pkgid : toremove) {
for (const auto &pkgid : std::as_const(toremove)) {
auto res = kFilter<QVector<AbstractResource *>>(m_backend->resourcesByPackageName(pkgid), [](AbstractResource *res) {
return static_cast<PackageKitResource *>(res)->isCritical();
});
......
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