]> git.lyx.org Git - lyx.git/commitdiff
Store spellchecker_esc_chars as a docstring
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 21 Jul 2024 19:33:01 +0000 (21:33 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 21 Jul 2024 19:35:14 +0000 (21:35 +0200)
This is a minor optimization to avoid calling from_utf8() repeatedly
on a hot path.

src/LyXRC.cpp
src/LyXRC.h
src/Paragraph.cpp
src/frontends/qt/GuiPrefs.cpp

index fb9eb8f303d41143c7899531bd91690fe028bbec..ce0d4ee92a35bfdad3dc2a8d28807dd9002fa0fc 100644 (file)
@@ -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;
index e0c2da31789e73dbea1b7a84258703633fe28687..a8b4b04452b42c18f84c2840f57cb89ca71fb9db 100644 (file)
@@ -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?
index 369d03ee836c238f6834e30601ec6e2e7be5dfc6..d21e86ebbf464cca2c4173a375c28219dec212df 100644 (file)
@@ -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);
 }
 
 
index 230d377a2b2c2ae201e90fad34993f9973b84498..6eac7d9fab9a9bda489a4b7b9676e9a7d46fd935 100644 (file)
@@ -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();