diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-12-09 13:17:45 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-12-14 00:25:07 +0800 |
commit | 662dd823fddecacb903ebb4a7a22fa7ebcc8391b (patch) | |
tree | 51f1845e14111e00100f8b69903940e76b88ef5f | |
parent | 10c20babaebbdd913368b1c521272a1d202f3e8a (diff) | |
download | subsurface-662dd823fddecacb903ebb4a7a22fa7ebcc8391b.tar.gz |
Cleanup: remove split_dive_*() functions
In 302f6adb79681da3fe53336f1e4c7525f46fd47d dive-splitting was made
undo-able. To this goal, the dive-splitting functions were split in
two types: Those that operate directly on the divelist and those that
only allocate the dives. The former are not in use anymore, therefore
remove them. Since only the latter remain, remove the "_dont_insert"
appendix of the name.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | core/dive.c | 33 | ||||
-rw-r--r-- | core/dive.h | 6 | ||||
-rw-r--r-- | desktop-widgets/command_divelist.cpp | 4 |
3 files changed, 6 insertions, 37 deletions
diff --git a/core/dive.c b/core/dive.c index f37b42a0b..30a552a33 100644 --- a/core/dive.c +++ b/core/dive.c @@ -3686,17 +3686,6 @@ static int split_dive_at(const struct dive *dive, int a, int b, struct dive **ou return nr; } -static void finish_split(int nr, struct dive *old, struct dive *d1, struct dive *d2) -{ - if (old->divetrip) { - add_dive_to_trip(d1, old->divetrip); - add_dive_to_trip(d2, old->divetrip); - } - delete_single_dive(nr); - add_single_dive(nr, d1); - add_single_dive(nr + 1, d2); -} - /* in freedive mode we split for as little as 10 seconds on the surface, * otherwise we use a minute */ static bool should_split(const struct divecomputer *dc, int t1, int t2) @@ -3716,7 +3705,7 @@ static bool should_split(const struct divecomputer *dc, int t1, int t2) * * In other words, this is a (simplified) reversal of the dive merging. */ -int split_dive_dont_insert(const struct dive *dive, struct dive **new1, struct dive **new2) +int split_dive(const struct dive *dive, struct dive **new1, struct dive **new2) { int i; int at_surface, surface_start; @@ -3758,16 +3747,7 @@ int split_dive_dont_insert(const struct dive *dive, struct dive **new1, struct d return -1; } -void split_dive(struct dive *dive) -{ - int nr; - struct dive *new1, *new2; - - if ((nr = split_dive_dont_insert(dive, &new1, &new2)) >= 0) - finish_split(nr, dive, new1, new2); -} - -int split_dive_at_time_dont_insert(const struct dive *dive, duration_t time, struct dive **new1, struct dive **new2) +int split_dive_at_time(const struct dive *dive, duration_t time, struct dive **new1, struct dive **new2) { int i = 0; struct sample *sample = dive->dc.sample; @@ -3783,15 +3763,6 @@ int split_dive_at_time_dont_insert(const struct dive *dive, duration_t time, str return split_dive_at(dive, i, i - 1, new1, new2); } -void split_dive_at_time(struct dive *dive, duration_t time) -{ - int nr; - struct dive *new1, *new2; - - if ((nr = split_dive_at_time_dont_insert(dive, time, &new1, &new2)) >= 0) - finish_split(nr, dive, new1, new2); -} - /* * "dc_maxtime()" is how much total time this dive computer * has for this dive. Note that it can differ from "duration" diff --git a/core/dive.h b/core/dive.h index 19c39214f..b4e7085b1 100644 --- a/core/dive.h +++ b/core/dive.h @@ -552,10 +552,8 @@ extern void fixup_dc_duration(struct divecomputer *dc); extern int dive_getUniqID(); extern unsigned int dc_airtemp(const struct divecomputer *dc); extern unsigned int dc_watertemp(const struct divecomputer *dc); -extern int split_dive_dont_insert(const struct dive *dive, struct dive **new1, struct dive **new2); -extern void split_dive(struct dive *); -extern int split_dive_at_time_dont_insert(const struct dive *dive, duration_t time, struct dive **new1, struct dive **new2); -extern void split_dive_at_time(struct dive *dive, duration_t time); +extern int split_dive(const struct dive *dive, struct dive **new1, struct dive **new2); +extern int split_dive_at_time(const struct dive *dive, duration_t time, struct dive **new1, struct dive **new2); extern struct dive *merge_dives(const struct dive *a, const struct dive *b, int offset, bool prefer_downloaded, struct dive_trip **trip); extern struct dive *try_to_merge(struct dive *a, struct dive *b, bool prefer_downloaded); extern struct event *clone_event(const struct event *src_ev); diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp index fcaeb0b19..91adb3725 100644 --- a/desktop-widgets/command_divelist.cpp +++ b/desktop-widgets/command_divelist.cpp @@ -758,8 +758,8 @@ SplitDives::SplitDives(dive *d, duration_t time) // Split the dive dive *new1, *new2; int idx = time.seconds < 0 ? - split_dive_dont_insert(d, &new1, &new2) : - split_dive_at_time_dont_insert(d, time, &new1, &new2); + split_dive(d, &new1, &new2) : + split_dive_at_time(d, time, &new1, &new2); // If this didn't work, simply return. Empty arrays indicate that nothing is to be done. if (idx < 0) |