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/dive.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/dive.c') diff --git a/core/dive.c b/core/dive.c index 6d9945932..0cf0df780 100644 --- a/core/dive.c +++ b/core/dive.c @@ -4308,3 +4308,11 @@ struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, s *evp = ev; return res; } + +/* get the gas at a certain time during the dive */ +struct gasmix get_gasmix_at_time(struct dive *d, struct divecomputer *dc, duration_t time) +{ + struct event *ev = NULL; + struct gasmix gasmix = { 0 }; + return get_gasmix(d, dc, time.seconds, &ev, &gasmix); +} -- cgit v1.2.3-70-g09d2