core: remove dive_site member from merge_result

All callers were just using that member to set the dive_site
in the resulting dive. We might just do that in the called
function [merge_dives()].

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-08-31 09:38:37 +02:00 committed by Michael Keller
parent 5b46d8cc33
commit 27a89b0232
3 changed files with 6 additions and 10 deletions

View file

@ -1175,14 +1175,13 @@ merge_result dive_table::merge_dives(const struct dive &a_in, const struct dive
res.trip = get_preferred_trip(a, b);
/* we take the first dive site, unless it's empty */
res.site = a->dive_site && !a->dive_site->is_empty() ? a->dive_site : b->dive_site;
if (res.site && !res.site->has_gps_location() && b->dive_site && b->dive_site->has_gps_location()) {
res.dive->dive_site = a->dive_site && !a->dive_site->is_empty() ? a->dive_site : b->dive_site;
if (res.dive->dive_site && !res.dive->dive_site->has_gps_location() && b->dive_site && b->dive_site->has_gps_location()) {
/* we picked the first dive site and that didn't have GPS data, but the new dive has
* GPS data (that could be a download from a GPS enabled dive computer).
* Keep the dive site, but add the GPS data */
res.site->location = b->dive_site->location;
res.dive->dive_site->location = b->dive_site->location;
}
res.dive->dive_site = res.site;
fixup_dive(*res.dive);
return res;
@ -1206,8 +1205,7 @@ struct std::unique_ptr<dive> dive_table::try_to_merge(const struct dive &a, cons
if (!a.likely_same(b))
return {};
auto [res, trip, site] = merge_dives(a, b, 0, prefer_downloaded);
res->dive_site = site; /* Caller has to call site->add_dive()! */
auto [res, trip] = merge_dives(a, b, 0, prefer_downloaded);
return std::move(res);
}