From 2df1e0b3429078dbbfe214ecc4e2a4e6339d2d64 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 7 Feb 2016 07:22:41 -0800 Subject: Don't run time consuming gas interpolation without any data If the user hasn't set any pressures at all there is no point in trying to interpolate all these data. Signed-off-by: Dirk Hohndel --- subsurface-core/gaspressures.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'subsurface-core') diff --git a/subsurface-core/gaspressures.c b/subsurface-core/gaspressures.c index 5f46d6080..66ec7e3aa 100644 --- a/subsurface-core/gaspressures.c +++ b/subsurface-core/gaspressures.c @@ -369,6 +369,18 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s pr_track_t *track_pr[MAX_CYLINDERS] = { NULL, }; pr_track_t *current = NULL; bool missing_pr = false; + bool found_any_pr_data = false; + + /* if we have no pressure data whatsoever, this is pointless, so let's just return */ + for (i = 0; i < MAX_CYLINDERS; i++) { + if (dive->cylinder[i].start.mbar || dive->cylinder[i].sample_start.mbar || + dive->cylinder[i].end.mbar || dive->cylinder[i].sample_end.mbar) { + found_any_pr_data = true; + break; + } + } + if (!found_any_pr_data) + return; for (i = 0; i < pi->nr; i++) { struct plot_data *entry = pi->entry + i; -- cgit v1.2.3-70-g09d2