Store spellchecker_esc_chars as a docstring

This is a minor optimization to avoid calling from_utf8() repeatedly
on a hot path.
This commit is contained in:
Jean-Marc Lasgouttes 2024-07-21 21:33:01 +02:00
parent 2f7d759108
commit 23379bb1d5
4 changed files with 5 additions and 5 deletions

View 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;

View 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?

View 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);
}

View 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();