[LyX/master] Store spellchecker_esc_chars as a docstring

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sun Jul 21 19:35:25 UTC 2024


commit 23379bb1d596359a0922b9d14e6f83c003ecd14d
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Sun Jul 21 21:33:01 2024 +0200

    Store spellchecker_esc_chars as a docstring
    
    This is a minor optimization to avoid calling from_utf8() repeatedly
    on a hot path.
---
 src/LyXRC.cpp                 | 2 +-
 src/LyXRC.h                   | 2 +-
 src/Paragraph.cpp             | 4 ++--
 src/frontends/qt/GuiPrefs.cpp | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index fb9eb8f303..ce0d4ee92a 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -2419,7 +2419,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
 	case RC_ESC_CHARS:
 		if (ignore_system_lyxrc ||
 		    spellchecker_esc_chars != system_lyxrc.spellchecker_esc_chars) {
-			os << "\\escape_chars \"" << spellchecker_esc_chars << "\"\n";
+			os << "\\escape_chars \"" << to_utf8(spellchecker_esc_chars) << "\"\n";
 		}
 		if (tag != RC_LAST)
 			break;
diff --git a/src/LyXRC.h b/src/LyXRC.h
index e0c2da3178..a8b4b04452 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -372,7 +372,7 @@ public:
 	/// Alternate language for spellchecker
 	std::string spellchecker_alt_lang;
 	/// Escape characters
-	std::string spellchecker_esc_chars;
+	docstring spellchecker_esc_chars;
 	/// Accept compound words in spellchecker?
 	bool spellchecker_accept_compound = false;
 	/// spellcheck continuously?
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 369d03ee83..d21e86ebbf 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -4275,8 +4275,8 @@ bool Paragraph::isWordSeparator(pos_type pos, bool const ignore_deleted) const
 		return false;
 	char_type const c = d->text_[pos];
 	// We want to pass the escape chars to the spellchecker
-	docstring const escape_chars = from_utf8(lyxrc.spellchecker_esc_chars);
-	return !isLetterChar(c) && !isDigitASCII(c) && !contains(escape_chars, c);
+	return !isLetterChar(c) && !isDigitASCII(c)
+	       && !contains(lyxrc.spellchecker_esc_chars, c);
 }
 
 
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index 230d377a2b..6eac7d9fab 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -1515,7 +1515,7 @@ void PrefSpellchecker::applyRC(LyXRC & rc) const
 	if (!speller.empty())
 		rc.spellchecker = speller;
 	rc.spellchecker_alt_lang = fromqstr(altLanguageED->text());
-	rc.spellchecker_esc_chars = fromqstr(escapeCharactersED->text());
+	rc.spellchecker_esc_chars = qstring_to_ucs4(escapeCharactersED->text());
 	rc.spellchecker_accept_compound = compoundWordCB->isChecked();
 	rc.spellcheck_continuously = spellcheckContinuouslyCB->isChecked();
 	rc.spellcheck_notes = spellcheckNotesCB->isChecked();


More information about the lyx-cvs mailing list