diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-12 12:49:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-13 10:58:26 +0200 |
commit | 8ad920befe1290c40ef762e8d7d9797b1924f5d2 (patch) | |
tree | a14719028570609c8f1b4337b8fd090fcdd93f59 /starmath/source/mathml | |
parent | 388bed014ad19a23fa9879bc31a8088f34157a48 (diff) |
tdf#121740 reduce cost of mathml parsing
by re-using OUString instances instead of allocating new ones for each
SmToken
Change-Id: Ia897427d6c1ffeb0e741dea90fde1f4d56a70175
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134264
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/source/mathml')
-rw-r--r-- | starmath/source/mathml/export.cxx | 18 | ||||
-rw-r--r-- | starmath/source/mathml/mathmlexport.cxx | 3 | ||||
-rw-r--r-- | starmath/source/mathml/starmathdatabase.cxx | 19 |
3 files changed, 19 insertions, 21 deletions
diff --git a/starmath/source/mathml/export.cxx b/starmath/source/mathml/export.cxx index 7115e7a1a8f3..ab737c125491 100644 --- a/starmath/source/mathml/export.cxx +++ b/starmath/source/mathml/export.cxx @@ -785,11 +785,10 @@ void SmMLExport::exportMlAttributes(const SmMlElement* pMlElement) break; case SmMlAttributeValueMathbackground::MlRgb: { - OUString aTextColor - = OUString::createFromAscii(starmathdatabase::Identify_Color_MATHML( - sal_uInt32(aAttributeValue->m_aCol)) - .pIdent); - addAttribute(XML_MATHBACKGROUND, aTextColor); + const OUString& rTextColor = starmathdatabase::Identify_Color_MATHML( + sal_uInt32(aAttributeValue->m_aCol)) + .aIdent; + addAttribute(XML_MATHBACKGROUND, rTextColor); break; } default: @@ -807,11 +806,10 @@ void SmMLExport::exportMlAttributes(const SmMlElement* pMlElement) break; case SmMlAttributeValueMathcolor::MlRgb: { - OUString aTextColor - = OUString::createFromAscii(starmathdatabase::Identify_Color_MATHML( - sal_uInt32(aAttributeValue->m_aCol)) - .pIdent); - addAttribute(XML_MATHCOLOR, aTextColor); + const OUString& rTextColor = starmathdatabase::Identify_Color_MATHML( + sal_uInt32(aAttributeValue->m_aCol)) + .aIdent; + addAttribute(XML_MATHCOLOR, rTextColor); break; } default: diff --git a/starmath/source/mathml/mathmlexport.cxx b/starmath/source/mathml/mathmlexport.cxx index 142ba6fd665c..0fb2573b5b80 100644 --- a/starmath/source/mathml/mathmlexport.cxx +++ b/starmath/source/mathml/mathmlexport.cxx @@ -1142,8 +1142,7 @@ void SmXMLExport::ExportFont(const SmNode* pNode, int nLevel) case TMATHMLCOL: { nc = pNode->GetToken().cMathChar.toUInt32(16); - OUString sssStr - = OUString::createFromAscii(starmathdatabase::Identify_Color_MATHML(nc).pIdent); + const OUString& sssStr = starmathdatabase::Identify_Color_MATHML(nc).aIdent; AddAttribute(XML_NAMESPACE_MATH, XML_MATHCOLOR, sssStr); } break; diff --git a/starmath/source/mathml/starmathdatabase.cxx b/starmath/source/mathml/starmathdatabase.cxx index d52a5fa37cdc..66bdf3f3400c 100644 --- a/starmath/source/mathml/starmathdatabase.cxx +++ b/starmath/source/mathml/starmathdatabase.cxx @@ -743,13 +743,14 @@ SmColorTokenTableEntry starmathdatabase::Identify_Color_DVIPSNAMES(sal_uInt32 cC return SmColorTokenTableEntry("", TRGBA, cColor); } -const SmColorTokenTableEntry* starmathdatabase::Identify_ColorName_Parser(const OUString& colorname) +const SmColorTokenTableEntry* +starmathdatabase::Identify_ColorName_Parser(std::u16string_view colorname) { - if (colorname.isEmpty()) + if (colorname.empty()) return &aColorTokenTableERROR[0]; for (auto i = std::begin(aColorTokenTableParse); i < std::end(aColorTokenTableParse); ++i) { - sal_Int32 matches = colorname.compareToIgnoreAsciiCaseAscii(i->pIdent); + sal_Int32 matches = o3tl::compareToIgnoreAsciiCase(colorname, i->aIdent); if (matches == 0) return i; if (matches < 0) @@ -757,9 +758,9 @@ const SmColorTokenTableEntry* starmathdatabase::Identify_ColorName_Parser(const } return &aColorTokenTableERROR[0]; } -SmColorTokenTableEntry starmathdatabase::Identify_ColorName_HTML(const OUString& colorname) +SmColorTokenTableEntry starmathdatabase::Identify_ColorName_HTML(std::u16string_view colorname) { - if (colorname.isEmpty()) + if (colorname.empty()) return SmColorTokenTableEntry("", TERROR, COL_SM_BLACK); if (colorname[0] == '#') { @@ -768,7 +769,7 @@ SmColorTokenTableEntry starmathdatabase::Identify_ColorName_HTML(const OUString& } for (auto i = std::begin(aColorTokenTableHTML); i < std::end(aColorTokenTableHTML); ++i) { - sal_Int32 matches = colorname.compareToIgnoreAsciiCaseAscii(i->pIdent); + sal_Int32 matches = o3tl::compareToIgnoreAsciiCase(colorname, i->aIdent); if (matches == 0) return i; if (matches < 0) @@ -777,13 +778,13 @@ SmColorTokenTableEntry starmathdatabase::Identify_ColorName_HTML(const OUString& return SmColorTokenTableEntry("", TERROR, COL_SM_BLACK); } const SmColorTokenTableEntry* -starmathdatabase::Identify_ColorName_DVIPSNAMES(const OUString& colorname) +starmathdatabase::Identify_ColorName_DVIPSNAMES(std::u16string_view colorname) { - if (colorname.isEmpty()) + if (colorname.empty()) return &aColorTokenTableERROR[0]; for (auto i = std::begin(aColorTokenTableDVIPS); i < std::end(aColorTokenTableDVIPS); ++i) { - sal_Int32 matches = colorname.compareToIgnoreAsciiCaseAscii(i->pIdent); + sal_Int32 matches = o3tl::compareToIgnoreAsciiCase(colorname, i->aIdent); if (matches == 0) return i; if (matches < 0) |