From bd8126a709f81631f949c374f4236861b519ea48 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Mon, 31 Aug 2015 23:25:28 +0200 Subject: Calculate ceiling only when it is needed So far, add_segment() returned a tissue tolerance (i.e. ceiling) computed just in its return statement. This tissue_tolerance needed to be dragged around until it was needed or be dropped if not needed at all. As for VPM-B, this ceiling computation is a bit expensive, this patch calls the computation function tissue_tolerance_calc() when the value is actually needed and not before. This changes the signature of some functions. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- divelist.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'divelist.c') diff --git a/divelist.c b/divelist.c index 85a70f9fd..d9a3e2a7b 100644 --- a/divelist.c +++ b/divelist.c @@ -364,12 +364,12 @@ double init_decompression(struct dive *dive) unsigned int surface_time; timestamp_t when, lasttime = 0, laststart = 0; bool deco_init = false; - double tissue_tolerance, surface_pressure; + double surface_pressure; if (!dive) return 0.0; - tissue_tolerance = surface_pressure = get_surface_pressure_in_mbar(dive, true) / 1000.0; + surface_pressure = get_surface_pressure_in_mbar(dive, true) / 1000.0; divenr = get_divenr(dive); when = dive->when; i = divenr; @@ -415,7 +415,7 @@ double init_decompression(struct dive *dive) if (pdive->when > lasttime) { surface_time = pdive->when - lasttime; lasttime = pdive->when + pdive->duration.seconds; - tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0, dive, prefs.decosac); + add_segment(surface_pressure, &air, surface_time, 0, dive, prefs.decosac); #if DECO_CALC_DEBUG & 2 printf("after surface intervall of %d:%02u\n", FRACTION(surface_time, 60)); dump_tissues(); @@ -426,7 +426,7 @@ double init_decompression(struct dive *dive) if (lasttime && dive->when > lasttime) { surface_time = dive->when - lasttime; surface_pressure = get_surface_pressure_in_mbar(dive, true) / 1000.0; - tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0, dive, prefs.decosac); + add_segment(surface_pressure, &air, surface_time, 0, dive, prefs.decosac); #if DECO_CALC_DEBUG & 2 printf("after surface intervall of %d:%02u\n", FRACTION(surface_time, 60)); dump_tissues(); @@ -440,7 +440,7 @@ double init_decompression(struct dive *dive) dump_tissues(); #endif } - return tissue_tolerance; + return tissue_tolerance_calc(dive, surface_pressure); } void update_cylinder_related_info(struct dive *dive) -- cgit v1.2.3-70-g09d2