From 22b232661a2ba7751c3548e1a30d0d92fc9ceec4 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 7 Sep 2024 15:08:50 +0200 Subject: [PATCH] planner: remove cloneDivePlan() This was a trivial one-liner and is not needed. Signed-off-by: Berthold Stoeger --- qt-models/diveplannermodel.cpp | 15 +++++---------- qt-models/diveplannermodel.h | 1 - 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 913d76d6f..5886c446b 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -1128,7 +1128,7 @@ void DivePlannerPointsModel::updateDiveProfile() if (isPlanner() && shouldComputeVariations()) { auto plan_copy = std::make_unique(); lock_planner(); - cloneDiveplan(diveplan, *plan_copy); + *plan_copy = diveplan; unlock_planner(); #ifdef VARIATIONS_IN_BACKGROUND // Since we're calling computeVariations asynchronously and plan_deco_state is allocated @@ -1177,11 +1177,6 @@ void DivePlannerPointsModel::saveDuplicatePlan() createPlan(true); } -void DivePlannerPointsModel::cloneDiveplan(const struct diveplan &plan_src, struct diveplan &plan_copy) -{ - plan_copy = plan_src; -} - int DivePlannerPointsModel::analyzeVariations(const std::vector &min, const std::vector &mid, const std::vector &max, const char *unit) { auto sum_time = [](int time, const decostop &ds) { return ds.time + time; }; @@ -1243,7 +1238,7 @@ void DivePlannerPointsModel::computeVariations(std::unique_ptr depth_units = tr("ft"); } - cloneDiveplan(*original_plan, plan_copy); + plan_copy = *original_plan; if (plan_copy.dp.size() < 2) return; if (my_instance != instanceCounter) @@ -1251,7 +1246,7 @@ void DivePlannerPointsModel::computeVariations(std::unique_ptr plan(&ds, plan_copy, dive.get(), dcNr, 1, original, cache, true, false); save.restore(&ds, false); - cloneDiveplan(*original_plan, plan_copy); + plan_copy = *original_plan; second_to_last(plan_copy.dp).depth.mm += delta_depth.mm; plan_copy.dp.back().depth.mm += delta_depth.mm; if (my_instance != instanceCounter) @@ -1266,7 +1261,7 @@ void DivePlannerPointsModel::computeVariations(std::unique_ptr plan(&ds, plan_copy, dive.get(), dcNr, 1, shallower, cache, true, false); save.restore(&ds, false); - cloneDiveplan(*original_plan, plan_copy); + plan_copy = *original_plan; plan_copy.dp.back().time += delta_time.seconds; if (my_instance != instanceCounter) return; @@ -1322,7 +1317,7 @@ void DivePlannerPointsModel::createPlan(bool saveAsNew) if (shouldComputeVariations()) { auto plan_copy = std::make_unique(); lock_planner(); - cloneDiveplan(diveplan, *plan_copy); + *plan_copy = diveplan; unlock_planner(); computeVariations(std::move(plan_copy), &ds_after_previous_dives); } diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h index 38adefe5f..abfcbab5c 100644 --- a/qt-models/diveplannermodel.h +++ b/qt-models/diveplannermodel.h @@ -130,7 +130,6 @@ private: void updateDiveProfile(); // Creates a temporary plan and updates the dive profile with it. void createTemporaryPlan(); struct diveplan diveplan; - void cloneDiveplan(const struct diveplan &plan_src, struct diveplan &plan_copy); void computeVariationsDone(QString text); void computeVariations(std::unique_ptr plan, const struct deco_state *ds); void computeVariationsFreeDeco(std::unique_ptr plan, std::unique_ptr ds);