aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-08-16 19:10:10 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-23 05:16:38 -0700
commit360f07e4533d4ede7ba494724382fc8dbcb4649c (patch)
tree73a222ad3469e8a7fd085cb2671d12dac664aeac /qt-models
parent5c4569247a31cf9f52238bd2b3f9c87b8f79933a (diff)
downloadsubsurface-360f07e4533d4ede7ba494724382fc8dbcb4649c.tar.gz
Cleanup: pass gasmix by value
In a previous commit, the get_gasmix_* functions were changed to return by value. For consistency, also pass gasmix by value. Note that on common 64-bit platforms struct gasmix is the size of a pointer [2 * 32 bit vs. 64 bit] and therefore uses the same space on the stack. On 32-bit platforms, the stack use is probably doubled, but in return a dereference is avoided. Supporting arbitrary gas-mixes (H2, Ar, ...) will be such an invasive change that going back to pointers is probably the least of our worries. This commit is a step in const-ifying input parameters (passing by value is the ultimate way of signaling that the input parameter will not be changed [unless there are references to said parameter]). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/cylindermodel.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index 9a093112c..11d4595ee 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -100,7 +100,7 @@ static QVariant gas_volume_tooltip(cylinder_t *cyl, pressure_t p)
if (!vol)
return QVariant();
- Z = gas_compressibility_factor(&cyl->gasmix, p.mbar / 1000.0);
+ Z = gas_compressibility_factor(cyl->gasmix, p.mbar / 1000.0);
return gas_volume_string(vol, "(Z=") + QString("%1)").arg(Z, 0, 'f', 3);
}
@@ -212,14 +212,14 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
} else {
pressure_t modpO2;
modpO2.mbar = prefs.bottompo2;
- ret = get_depth_string(gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(1,1)), true);
+ ret = get_depth_string(gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(1,1)), true);
}
break;
case MND:
if (cyl->bestmix_he)
ret = QString("*");
else
- ret = get_depth_string(gas_mnd(&cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1)), true);
+ ret = get_depth_string(gas_mnd(cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1)), true);
break;
case USE:
ret = gettextFromC::tr(cylinderuse_text[cyl->cylinder_use]);
@@ -353,15 +353,15 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
if (CHANGED()) {
cyl->gasmix.o2 = string_to_fraction(qPrintable(vString));
// fO2 + fHe must not be greater than 1
- if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
- cyl->gasmix.he.permille = 1000 - get_o2(&cyl->gasmix);
+ if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
+ cyl->gasmix.he.permille = 1000 - get_o2(cyl->gasmix);
pressure_t modpO2;
if (displayed_dive.dc.divemode == PSCR)
- modpO2.mbar = prefs.decopo2 + (1000 - get_o2(&cyl->gasmix)) * SURFACE_PRESSURE *
+ modpO2.mbar = prefs.decopo2 + (1000 - get_o2(cyl->gasmix)) * SURFACE_PRESSURE *
prefs.o2consumption / prefs.decosac / prefs.pscr_ratio;
else
modpO2.mbar = prefs.decopo2;
- cyl->depth = gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
+ cyl->depth = gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
cyl->bestmix_o2 = false;
changed = true;
}
@@ -370,8 +370,8 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
if (CHANGED()) {
cyl->gasmix.he = string_to_fraction(qPrintable(vString));
// fO2 + fHe must not be greater than 1
- if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
- cyl->gasmix.o2.permille = 1000 - get_he(&cyl->gasmix);
+ if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
+ cyl->gasmix.o2.permille = 1000 - get_he(cyl->gasmix);
cyl->bestmix_he = false;
changed = true;
}
@@ -395,7 +395,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
}
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
- cyl->depth = gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
+ cyl->depth = gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
changed = true;
}
break;
@@ -588,8 +588,8 @@ void CylindersModel::updateDecoDepths(pressure_t olddecopo2)
cylinder_t *cyl = &displayed_dive.cylinder[i];
/* If the gas's deco MOD matches the old pO2, it will have been automatically calculated and should be updated.
* If they don't match, we should leave the user entered depth as it is */
- if (cyl->depth.mm == gas_mod(&cyl->gasmix, olddecopo2, &displayed_dive, M_OR_FT(3, 10)).mm) {
- cyl->depth = gas_mod(&cyl->gasmix, decopo2, &displayed_dive, M_OR_FT(3, 10));
+ if (cyl->depth.mm == gas_mod(cyl->gasmix, olddecopo2, &displayed_dive, M_OR_FT(3, 10)).mm) {
+ cyl->depth = gas_mod(cyl->gasmix, decopo2, &displayed_dive, M_OR_FT(3, 10));
}
}
emit dataChanged(createIndex(0, 0), createIndex(MAX_CYLINDERS - 1, COLUMNS - 1));
@@ -609,18 +609,18 @@ bool CylindersModel::updateBestMixes()
if (cyl->bestmix_o2) {
cyl->gasmix.o2 = best_o2(displayed_dive.maxdepth, &displayed_dive);
// fO2 + fHe must not be greater than 1
- if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
- cyl->gasmix.he.permille = 1000 - get_o2(&cyl->gasmix);
+ if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
+ cyl->gasmix.he.permille = 1000 - get_o2(cyl->gasmix);
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
- cyl->depth = gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
+ cyl->depth = gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
gasUpdated = true;
}
if (cyl->bestmix_he) {
cyl->gasmix.he = best_he(displayed_dive.maxdepth, &displayed_dive);
// fO2 + fHe must not be greater than 1
- if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
- cyl->gasmix.o2.permille = 1000 - get_he(&cyl->gasmix);
+ if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
+ cyl->gasmix.o2.permille = 1000 - get_he(cyl->gasmix);
gasUpdated = true;
}
}