[LyX/master] use std::move() instead of copying when value is no longer used

Juergen Spitzmueller spitz at lyx.org
Sat Sep 7 10:52:00 UTC 2024


commit e685d31f5aadadd9c84c80a604818d49f5853dbf
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sat Sep 7 12:50:27 2024 +0200

    use std::move() instead of copying when value is no longer used
    
    This is mainly to shut down coverity which nowadays nags on this.
    I am not sure whether we really gain something in these cases.
---
 src/BufferView.cpp          | 2 +-
 src/Encoding.cpp            | 2 +-
 src/insets/InsetNomencl.cpp | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index b1ac2da82c..eeba7b86c3 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1707,7 +1707,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 			string label = dit.innerParagraph().getLabelForXRef();
 			if (!label.empty()) {
 				// if the paragraph has a label, we refer to this
-				string const arg = (type.empty()) ? label : label + " " + type;
+				string const arg = (type.empty()) ? move(label) : move(label) + " " + type;
 				lyx::dispatch(FuncRequest(LFUN_REFERENCE_INSERT, arg));
 				break;
 			} else {
diff --git a/src/Encoding.cpp b/src/Encoding.cpp
index cff17ee051..267298927f 100644
--- a/src/Encoding.cpp
+++ b/src/Encoding.cpp
@@ -798,7 +798,7 @@ docstring Encodings::convertLaTeXCommands(docstring const & str, bool const lite
 		if (!cnvtd.empty()) {
 			// it did, so we'll take that bit and proceed with what's left
 			ret += cnvtd;
-			val = rem;
+			val = move(rem);
 			continue;
 		}
 		// it's a command of some sort
diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp
index 484d731abe..012ef4fc88 100644
--- a/src/insets/InsetNomencl.cpp
+++ b/src/insets/InsetNomencl.cpp
@@ -440,7 +440,7 @@ docstring nomenclWidest(Buffer const & buffer)
 				msymb.size();
 			if (wx > w) {
 				w = wx;
-				symb = symbol;
+				symb = move(symbol);
 			}
 		}
 	}


More information about the lyx-cvs mailing list