optimize selectedDivesGasUsed()

-return the result instead of storing in a parameter, we now know that the list
 contains only those results that are generated in the function
-allocate the result with the correct length right from the start
-do not iterate over keys of a map and then do a map lookup to get the value but
 use an iterator that gives us both right from the start
-remove one call alltogether as the results were not used there

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
This commit is contained in:
Rolf Eike Beer 2019-04-03 23:05:44 +02:00 committed by Dirk Hohndel
parent 1f4777a287
commit 36644dc9f7
4 changed files with 9 additions and 22 deletions

View file

@ -97,10 +97,9 @@ void TabDiveStatistics::updateData()
ui->timeLimits->setMinimum("");
}
QVector<QPair<QString, int> > gasUsed;
QVector<QPair<QString, int> > gasUsed = selectedDivesGasUsed();
QString gasUsedString;
volume_t vol;
selectedDivesGasUsed(gasUsed);
for (int j = 0; j < MAX_CYLINDERS; j++) {
if (gasUsed.isEmpty())
break;