From 5c4569247a31cf9f52238bd2b3f9c87b8f79933a Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 16 Aug 2018 17:11:51 +0200 Subject: Cleanup: unify get_gas_at_time() and get_gasmix() There were two functions for getting gas-mixes at a certain timestamp: - get_gasmix() for repeated queries. - get_gas_at_time() for a single query. Since the latter is a special case of the former, simply call the former in the latter. Moreover, rename to get_gasmix_at_time() for consistency. Replace on get_gasmix() call, which was outside of a loop by the corresponding get_gasmix_at_time() call. Signed-off-by: Berthold Stoeger --- core/planner.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'core/planner.c') diff --git a/core/planner.c b/core/planner.c index eefa94143..ec2436a70 100644 --- a/core/planner.c +++ b/core/planner.c @@ -81,22 +81,6 @@ bool diveplan_empty(struct diveplan *diveplan) return true; } -/* get the gas at a certain time during the dive */ -void get_gas_at_time(struct dive *dive, struct divecomputer *dc, duration_t time, struct gasmix *gas) -{ - // we always start with the first gas, so that's our gas - // unless an event tells us otherwise - struct event *event = dc->events; - *gas = dive->cylinder[0].gasmix; - while (event && event->time.seconds <= time.seconds) { - if (!strcmp(event->name, "gaschange")) { - int cylinder_idx = get_cylinder_index(dive, event); - *gas = dive->cylinder[cylinder_idx].gasmix; - } - event = event->next; - } -} - /* get the cylinder index at a certain time during the dive */ int get_cylinderid_at_time(struct dive *dive, struct divecomputer *dc, duration_t time) { @@ -164,7 +148,7 @@ int tissue_at_end(struct deco_state *ds, struct dive *dive, struct deco_state ** setpoint = sample[0].setpoint; t1 = sample->time; - get_gas_at_time(dive, dc, t0, &gas); + gas = get_gasmix_at_time(dive, dc, t0); if (i > 0) lastdepth = psample->depth; -- cgit v1.2.3-70-g09d2