diff options
author | Robert C. Helling <helling@atdotde.de> | 2015-08-31 23:25:28 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-31 15:17:39 -0700 |
commit | bd8126a709f81631f949c374f4236861b519ea48 (patch) | |
tree | 78a4e4912b845f7b0b47832b66c77b5064982f67 /divelist.c | |
parent | d9306125d97a90b3e589fe263ae08e12b7327773 (diff) | |
download | subsurface-bd8126a709f81631f949c374f4236861b519ea48.tar.gz |
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 <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 10 |
1 files changed, 5 insertions, 5 deletions
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) |