diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-06-15 12:47:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-06-16 12:41:43 +0200 |
commit | e51b4fc8c278bfa0b0671bbdb0ab35346881ebb7 (patch) | |
tree | 2fab442dfd820b5ff20c7a7d934a49b4d8b14777 /i18npool | |
parent | 4a40a42afc3ba551e6e58947fc2e44689979b629 (diff) |
speed up startup time
by avoid conversion of static locale data from sal_Unicode to OUString
data - we can declare the data as OUStringConstExpr arrays and then
no conversion is necessary.
Change-Id: Idd27071c1200d6ced2c4f43e10310df786fbc8fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153125
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/localedata/LocaleNode.cxx | 15 | ||||
-rw-r--r-- | i18npool/source/localedata/LocaleNode.hxx | 2 | ||||
-rw-r--r-- | i18npool/source/localedata/filewriter.cxx | 18 | ||||
-rw-r--r-- | i18npool/source/localedata/localedata.cxx | 10 |
4 files changed, 32 insertions, 13 deletions
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index 7b7dbd56c446..7531afa5aff2 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -2294,7 +2294,7 @@ void LCOutlineNumberingLevelNode::generateCode (const OFileWriter &of) const OUString useLocale = getAttr().getValueByName("ref"); if (!useLocale.isEmpty()) { useLocale = useLocale.replace( '-', '_'); - of.writeRefFunction3("getOutlineNumberingLevels_", useLocale); + of.writeOUStringRefFunction3("getOutlineNumberingLevels_", useLocale); return; } @@ -2331,7 +2331,7 @@ void LCOutlineNumberingLevelNode::generateCode (const OFileWriter &of) const { const char* name = attr[k]; OUString value = q.getValueByName( name ); - of.writeParameter("outline", name, value, + of.writeOUStringLiteralParameter("outline", name, value, sal::static_int_cast<sal_Int16>(i), sal::static_int_cast<sal_Int16>(j) ); } @@ -2372,7 +2372,7 @@ void LCOutlineNumberingLevelNode::generateCode (const OFileWriter &of) const { for( sal_Int32 j=0; j<nLevels.back(); j++ ) { - of.writeAsciiString("static const sal_Unicode* outline"); + of.writeAsciiString("static constexpr rtl::OUStringConstExpr outline"); of.writeAsciiString("Style"); of.writeInt( sal::static_int_cast<sal_Int16>(i) ); of.writeAsciiString("Level"); @@ -2387,7 +2387,7 @@ void LCOutlineNumberingLevelNode::generateCode (const OFileWriter &of) const of.writeInt( sal::static_int_cast<sal_Int16>(j) ); of.writeAsciiString(", "); } - of.writeAsciiString("NULL };\n"); + of.writeAsciiString(" };\n"); } } @@ -2396,8 +2396,7 @@ void LCOutlineNumberingLevelNode::generateCode (const OFileWriter &of) const for( sal_Int32 i=0; i<nStyles; i++ ) { - of.writeAsciiString("static const sal_Unicode** outline"); - of.writeAsciiString( "Style" ); + of.writeAsciiString("static constexpr rtl::OUStringConstExpr const * outlineStyle" ); of.writeInt( sal::static_int_cast<sal_Int16>(i) ); of.writeAsciiString("[] = { "); @@ -2413,7 +2412,7 @@ void LCOutlineNumberingLevelNode::generateCode (const OFileWriter &of) const } of.writeAsciiString("\n"); - of.writeAsciiString("static const sal_Unicode*** LCOutlineNumberingLevelsArray[] = {\n" ); + of.writeAsciiString("static constexpr rtl::OUStringConstExpr const * const * LCOutlineNumberingLevelsArray[] = {\n" ); for( sal_Int32 i=0; i<nStyles; i++ ) { of.writeAsciiString( "\t" ); @@ -2422,7 +2421,7 @@ void LCOutlineNumberingLevelNode::generateCode (const OFileWriter &of) const of.writeAsciiString(",\n"); } of.writeAsciiString("\tNULL\n};\n\n"); - of.writeFunction3("getOutlineNumberingLevels_", "outlineNbOfStyles", "outlineNbOfLevelsPerStyle", + of.writeOUStringFunction3("getOutlineNumberingLevels_", "outlineNbOfStyles", "outlineNbOfLevelsPerStyle", "outlineNbOfAttributesPerLevel", "LCOutlineNumberingLevelsArray"); } diff --git a/i18npool/source/localedata/LocaleNode.hxx b/i18npool/source/localedata/LocaleNode.hxx index f5c9072265a3..cedd3711fa78 100644 --- a/i18npool/source/localedata/LocaleNode.hxx +++ b/i18npool/source/localedata/LocaleNode.hxx @@ -54,7 +54,9 @@ public: void writeRefFunction2(const char *func, std::u16string_view useLocale) const; void writeOUStringRefFunction2(const char *func, std::u16string_view useLocale) const; void writeFunction3(const char *func, const char *style, const char* levels, const char* attr, const char *array) const; + void writeOUStringFunction3(const char *func, const char *style, const char* levels, const char* attr, const char *array) const; void writeRefFunction3(const char *func, std::u16string_view useLocale) const; + void writeOUStringRefFunction3(const char *func, std::u16string_view useLocale) const; void writeIntParameter(const char* pAsciiStr, const sal_Int16 count, sal_Int16 val) const; void writeOUStringLiteralIntParameter(const char* pAsciiStr, const sal_Int16 count, sal_Int16 val) const; bool writeDefaultParameter(const char* pAsciiStr, std::u16string_view str, sal_Int16 count) const; diff --git a/i18npool/source/localedata/filewriter.cxx b/i18npool/source/localedata/filewriter.cxx index a2ec7a1ea72d..9aaa27bbb47f 100644 --- a/i18npool/source/localedata/filewriter.cxx +++ b/i18npool/source/localedata/filewriter.cxx @@ -176,6 +176,15 @@ void OFileWriter::writeFunction3(const char *func, const char *style, const char fprintf(m_f, "\treturn %s;\n}\n", array); } +void OFileWriter::writeOUStringFunction3(const char *func, const char *style, const char* levels, const char* attr, const char *array) const +{ + fprintf(m_f, "const OUString *** SAL_CALL %s%s( sal_Int16& nStyles, sal_Int16& nLevels, sal_Int16& nAttributes )\n{\n", func, theLocale.c_str()); + fprintf(m_f, "\tnStyles = %s;\n", style); + fprintf(m_f, "\tnLevels = %s;\n", levels); + fprintf(m_f, "\tnAttributes = %s;\n", attr); + fprintf(m_f, "\treturn (const OUString ***) %s;\n}\n", array); +} + void OFileWriter::writeRefFunction3(const char *func, std::u16string_view useLocale) const { OString aRefLocale( OUStringToOString(useLocale, RTL_TEXTENCODING_ASCII_US) ); @@ -185,6 +194,15 @@ void OFileWriter::writeRefFunction3(const char *func, std::u16string_view useLoc fprintf(m_f, "\treturn %s%s(nStyles, nLevels, nAttributes);\n}\n", func, locale); } +void OFileWriter::writeOUStringRefFunction3(const char *func, std::u16string_view useLocale) const +{ + OString aRefLocale( OUStringToOString(useLocale, RTL_TEXTENCODING_ASCII_US) ); + const char* locale = aRefLocale.getStr(); + fprintf(m_f, "extern const OUString **** SAL_CALL %s%s(sal_Int16& nStyles, sal_Int16& nLevels, sal_Int16& nAttributes);\n", func, locale); + fprintf(m_f, "const OUString **** SAL_CALL %s%s(sal_Int16& nStyles, sal_Int16& nLevels, sal_Int16& nAttributes)\n{\n", func, theLocale.c_str()); + fprintf(m_f, "\treturn %s%s(nStyles, nLevels, nAttributes);\n}\n", func, locale); +} + void OFileWriter::writeIntParameter(const char* pAsciiStr, const sal_Int16 count, sal_Int16 val) const { fprintf(m_f, "static const sal_Unicode %s%d[] = {%d};\n", pAsciiStr, count, val); diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 5d7fabc727da..6408740885f3 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -44,7 +44,7 @@ using namespace com::sun::star; typedef OUString const * (* MyFuncOUString_Type)( sal_Int16&); typedef OUString const ** (* MyFunc_Type2)( sal_Int16&, sal_Int16& ); -typedef sal_Unicode const **** (* MyFunc_Type3)( sal_Int16&, sal_Int16&, sal_Int16& ); +typedef OUString const *** (* MyFunc_Type3)( sal_Int16&, sal_Int16&, sal_Int16& ); typedef OUString const * (* MyFunc_FormatCode)( sal_Int16&, sal_Unicode const *&, sal_Unicode const *& ); #ifndef DISABLE_DYNLOADING @@ -1327,20 +1327,20 @@ LocaleDataImpl::getOutlineNumberingLevels( const lang::Locale& rLocale ) sal_Int16 nStyles; sal_Int16 nLevels; sal_Int16 nAttributes; - sal_Unicode const **** p0 = func( nStyles, nLevels, nAttributes ); + OUString const *** p0 = func( nStyles, nLevels, nAttributes ); Sequence< Reference<container::XIndexAccess> > aRet( nStyles ); auto aRetRange = asNonConstRange(aRet); - sal_Unicode const **** pStyle = p0; + OUString const *** pStyle = p0; for( i=0; i<nStyles; i++ ) { int j; std::unique_ptr<OutlineNumberingLevel_Impl[]> level(new OutlineNumberingLevel_Impl[ nLevels+1 ]); - sal_Unicode const *** pLevel = pStyle[i]; + OUString const ** pLevel = pStyle[i]; for( j = 0; j < nLevels; j++ ) { - sal_Unicode const ** pAttribute = pLevel[j]; + OUString const * pAttribute = pLevel[j]; for( int k=0; k<nAttributes; k++ ) { OUString tmp( pAttribute[k] ); |