summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 35965208c..9483d9ab5 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -375,7 +375,7 @@ static bool lessThan(const QPair<QString, int> &a, const QPair<QString, int> &b)
return a.second < b.second;
}
-void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsedOrdered)
+QVector<QPair<QString, int>> selectedDivesGasUsed()
{
int i, j;
struct dive *d;
@@ -391,10 +391,13 @@ void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsedOrdered)
gasUsed[gasName] += diveGases[j].mliter;
}
}
- Q_FOREACH(const QString& gas, gasUsed.keys()) {
- gasUsedOrdered.append(qMakePair(gas, gasUsed[gas]));
- }
+ QVector<QPair<QString, int>> gasUsedOrdered;
+ gasUsedOrdered.reserve(gasUsed.size());
+ for (auto it = gasUsed.cbegin(); it != gasUsed.cend(); ++it)
+ gasUsedOrdered.append(qMakePair(it.key(), it.value()));
std::sort(gasUsedOrdered.begin(), gasUsedOrdered.end(), lessThan);
+
+ return gasUsedOrdered;
}
QString getUserAgent()