[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
wilder-5.14
Kai Uwe Broulik 9 years ago
parent 68cfef732d
commit 602e93dfdb
  1. 3
      libtaskmanager/tasksmodel.cpp

@ -824,8 +824,7 @@ bool TasksModel::Private::lessThan(const QModelIndex &left, const QModelIndex &r
}
if (leftScore == -1 || rightScore == -1) {
const QList<int> &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;

Loading…
Cancel
Save