From 602e93dfdb100ee5d1c3575aaa5f22bff0901634 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Mon, 25 Sep 2017 14:29:37 +0200 Subject: [PATCH] [TasksModel] Use std::acumulate on the QHash directly begin() and end() operate on the hash values. This avoids creating a temporary list just for this. Differential Revision: https://phabricator.kde.org/D7917 --- libtaskmanager/tasksmodel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp index cf6f95f89..ba10a98e2 100644 --- a/libtaskmanager/tasksmodel.cpp +++ b/libtaskmanager/tasksmodel.cpp @@ -824,8 +824,7 @@ bool TasksModel::Private::lessThan(const QModelIndex &left, const QModelIndex &r } if (leftScore == -1 || rightScore == -1) { - const QList &counts = activityTaskCounts.values(); - const int sumScore = std::accumulate(counts.begin(), counts.end(), 0); + const int sumScore = std::accumulate(activityTaskCounts.constBegin(), activityTaskCounts.constEnd(), 0); if (leftScore == -1) { leftScore = sumScore;