planner: use value semantics for computeVariations()

When computing the variations in a background thread, the
code has to work on a copy of the dive plan and the deco
state. Instead of passing a copy via a unique_ptr<>, simply
use value semantics when calling computeVariations().

This does an unnecessary copy of the deco state, when
computeVariations is not run in the background, but so what.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-11-15 14:07:36 +01:00 committed by Michael Keller
parent 9f55f167b2
commit 4f7d567571
2 changed files with 16 additions and 40 deletions

View file

@ -131,8 +131,7 @@ private:
void createTemporaryPlan();
struct diveplan diveplan;
void computeVariationsDone(QString text);
void computeVariations(std::unique_ptr<struct diveplan> plan, const struct deco_state *ds);
void computeVariationsFreeDeco(std::unique_ptr<struct diveplan> plan, std::unique_ptr<struct deco_state> ds);
void computeVariations(struct diveplan plan, struct deco_state ds); // Note: works on copies of plan and ds
int analyzeVariations(const std::vector<decostop> &min, const std::vector<decostop> &mid, const std::vector<decostop> &max, const char *unit);
struct dive *d;
int dcNr;