Profile: Refactor use of .

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2024-09-02 14:21:08 +12:00
parent db516b6d4e
commit 5b46d8cc33

View file

@ -673,7 +673,7 @@ static void setup_gas_sensor_pressure(const struct dive *dive, const struct dive
/* FIXME: The planner uses a dummy one-past-end cylinder for surface air! */ /* FIXME: The planner uses a dummy one-past-end cylinder for surface air! */
int num_cyl = pi.nr_cylinders + 1; int num_cyl = pi.nr_cylinders + 1;
std::vector<int> seen(num_cyl, 0); std::vector<int> seen(num_cyl, false);
std::vector<int> first(num_cyl, 0); std::vector<int> first(num_cyl, 0);
std::vector<int> last(num_cyl, INT_MAX); std::vector<int> last(num_cyl, INT_MAX);
@ -696,7 +696,7 @@ static void setup_gas_sensor_pressure(const struct dive *dive, const struct dive
first[cylinder_index] = time; first[cylinder_index] = time;
} }
seen[cylinder_index] = 1; seen[cylinder_index] = true;
prev = cylinder_index; prev = cylinder_index;
} }
@ -716,7 +716,8 @@ static void setup_gas_sensor_pressure(const struct dive *dive, const struct dive
* to plot pressures for even if we've seen it.. * to plot pressures for even if we've seen it..
*/ */
if (!start || !end || start == end) { if (!start || !end || start == end) {
seen[i] = -1; seen[i] = false;
continue; continue;
} }
@ -724,17 +725,18 @@ static void setup_gas_sensor_pressure(const struct dive *dive, const struct dive
if (seen[i]) if (seen[i])
continue; continue;
/* If it's only mentioned by other dc's, ignore it */ /* If it's mentioned by other dcs, ignore it */
for (auto &secondary: dive->dcs) { bool other_divecomputer = false;
if (dive->has_gaschange_event(&secondary, i)) { for (auto &secondary: dive->dcs)
seen[i] = -1; if (dive->has_gaschange_event(&secondary, i))
break; other_divecomputer = true;
}
} if (!other_divecomputer)
seen[i] = true;
} }
for (int i = 0; i < pi.nr_cylinders; i++) { for (int i = 0; i < pi.nr_cylinders; i++) {
if (seen[i] >= 0) { if (seen[i]) {
const cylinder_t *cyl = dive->get_cylinder(i); const cylinder_t *cyl = dive->get_cylinder(i);
add_plot_pressure(pi, first[i], i, cyl->start); add_plot_pressure(pi, first[i], i, cyl->start);