From 38fe08e5e1d822776d8dc25d9f4774c1f8d8f87a Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 1 Sep 2024 14:48:42 +0200 Subject: [PATCH] planner: use std::move() to store planner notes Avoids a copy and makes coverity happy (rightfully so). Signed-off-by: Berthold Stoeger --- core/plannernotes.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/plannernotes.cpp b/core/plannernotes.cpp index 70bb08592..360f7bb8d 100644 --- a/core/plannernotes.cpp +++ b/core/plannernotes.cpp @@ -143,9 +143,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d buf += format_string_std("%s %s
", translate("gettextFromC", "Warning:"), message); - // TODO: avoid copy - dive->notes = buf; - dive->notes = strdup(buf.c_str()); + dive->notes = std::move(buf); return; } @@ -162,8 +160,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d translate("gettextFromC", "Subsurface"), subsurface_canonical_version(), translate("gettextFromC", "dive plan (overlapping dives detected)")); - // TODO: avoid copy - dive->notes = buf; + dive->notes = std::move(buf); return; } else if (diveplan->surface_interval >= 48 * 60 *60) { buf += format_string_std("%s (%s) %s %s", @@ -630,8 +627,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d if (o2warning_exist) buf += "\n"; } - // TODO: avoid copy - dive->notes = buf; + dive->notes = std::move(buf); #ifdef DEBUG_PLANNER_NOTES printf("\n\n\tplannernotes\n\t\n%s\t\n\n", dive->notes); #endif