[LyX/master] Avoid a couple copies in Trans::addDeadKeys().

Jean-Marc Lasgouttes lasgouttes at lyx.org
Thu Sep 12 15:26:15 UTC 2024


commit 8ea9c2da03d97be8cd74d90bf4deed5f405d16df
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Thu Sep 12 17:24:32 2024 +0200

    Avoid a couple copies in Trans::addDeadKeys().
    
    Spotted by Coverity scan.
---
 src/Trans.cpp | 10 ++--------
 src/Trans.h   |  3 +++
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/Trans.cpp b/src/Trans.cpp
index 774c7ac7ce..2a3daf9df0 100644
--- a/src/Trans.cpp
+++ b/src/Trans.cpp
@@ -176,19 +176,13 @@ tex_accent getkeymod(string const &);
 
 void Trans::addDeadkey(tex_accent accent, docstring const & keys)
 {
-	KmodInfo tmp;
-	tmp.data = keys;
-	tmp.accent = accent;
-	kmod_list_[accent] = tmp;
+	kmod_list_[accent] = KmodInfo(keys, accent, KmodException());
 
 	for (char_type key : keys) {
 		// FIXME This is a hack.
 		// tmp is no valid UCS4 string, but misused to store the
 		// accent.
-		docstring tmpd;
-		tmpd += char_type(0);
-		tmpd += char_type(accent);
-		keymap_[key] = tmpd;
+		keymap_[key] = docstring() + char_type(0) + char_type(accent);
 	}
 }
 
diff --git a/src/Trans.h b/src/Trans.h
index aefb4adff0..c8d828e785 100644
--- a/src/Trans.h
+++ b/src/Trans.h
@@ -112,6 +112,9 @@ public:
 	///
 	KmodInfo() : accent(TEX_NOACCENT) {}
 	///
+	KmodInfo(docstring const & d, tex_accent a, KmodException const & e)
+		: data(d), accent(a), exception_list(e) {}
+	///
 	docstring data;
 	///
 	tex_accent accent;


More information about the lyx-cvs mailing list