From fe3021b88a414b6963891a65b738f52bc41e36a8 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 20 Aug 2020 07:31:04 +0200 Subject: cleanup: consistently use get_cylinder() accessor get_cylinder(d, i) is more readable than d->cylinders.cylinders[i]. Moreover, it does bound checking and is more flexible with respect to changing the core data structures. Most places already used this accessor, but some still accessed the cylinders directly. This patch unifies the accesses by consistently switching to get_cylinder(). The affected code is in C++ and accesses the cylinder as reference or object, whereas the get_cylinder() function is C and returns a pointer. This results in funky looking "*get_cylinder(d, i)" expressions. Arguably still better than the original. Signed-off-by: Berthold Stoeger --- qt-models/divesummarymodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-models/divesummarymodel.cpp') diff --git a/qt-models/divesummarymodel.cpp b/qt-models/divesummarymodel.cpp index d187f2b58..6ae5313e4 100644 --- a/qt-models/divesummarymodel.cpp +++ b/qt-models/divesummarymodel.cpp @@ -148,7 +148,7 @@ static void calculateDive(struct dive *dive, Stats &stats) // EAN dive ? for (int j = 0; j < dive->cylinders.nr; ++j) { - if (dive->cylinders.cylinders[j].gasmix.o2.permille > 210) { + if (get_cylinder(dive, j)->gasmix.o2.permille > 210) { stats.divesEAN++; break; } -- cgit v1.2.3-70-g09d2