From d8e509e5ebb7890f1f62bf8731cf445782cb6bc2 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sat, 15 Jul 2023 23:26:31 +0200 Subject: [PATCH] Cleanup and (maybe) speedup InsetMathChar::mathClass Profiling with hotspot show that it counts for more than it should and indeed using support::contains is a overkill here. I like the new code better anyway. I would be surprised to see that it makes a big difference, though. --- src/mathed/InsetMathChar.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp index d923d04dc0..71aba6f6f7 100644 --- a/src/mathed/InsetMathChar.cpp +++ b/src/mathed/InsetMathChar.cpp @@ -26,7 +26,6 @@ #include "frontends/FontMetrics.h" #include "support/debug.h" -#include "support/lstrings.h" #include "support/textutils.h" #include @@ -310,16 +309,27 @@ void InsetMathChar::htmlize(HtmlStream & ms) const MathClass InsetMathChar::mathClass() const { // this information comes from fontmath.ltx in LaTeX source. - char const ch = static_cast(char_); if (subst_) return string_to_class(subst_->extra); - else if (support::contains(",;", ch)) + + if (!isASCII(char_)) + return MC_ORD; + + switch (static_cast(char_)) { + case ',': + case ';': return MC_PUNCT; - else if (support::contains("([", ch)) + case '(': + case '[': return MC_OPEN; - else if (support::contains(")]!?", ch)) + case ')': + case ']': + case '!': + case '?': return MC_CLOSE; - else return MC_ORD; + default: + return MC_ORD; + } } -- 2.39.2