i18npool/source/localedata/LocaleNode.cxx |   12 ++++++------
 i18npool/source/localedata/LocaleNode.hxx |    3 +++
 i18npool/source/localedata/filewriter.cxx |   24 ++++++++++++++++++++++++
 i18npool/source/localedata/localedata.cxx |   20 +++++++++-----------
 4 files changed, 42 insertions(+), 17 deletions(-)

New commits:
commit b8b5e1e4149c409f42b02c09a7e4ff720af9873e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Jun 15 10:52:32 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Jun 16 08:32:21 2023 +0200

    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: I652f02f6f1f354e2dab4f0ca866e8499cd3c50f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153124
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/i18npool/source/localedata/LocaleNode.cxx 
b/i18npool/source/localedata/LocaleNode.cxx
index d89a7515c8da..7b7dbd56c446 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -2223,7 +2223,7 @@ void LCNumberingLevelNode::generateCode (const 
OFileWriter &of) const
     OUString useLocale =   getAttr().getValueByName("ref");
     if (!useLocale.isEmpty()) {
         useLocale = useLocale.replace( '-', '_');
-        of.writeRefFunction2("getContinuousNumberingLevels_", useLocale);
+        of.writeOUStringRefFunction2("getContinuousNumberingLevels_", 
useLocale);
         return;
     }
 
@@ -2243,7 +2243,7 @@ void LCNumberingLevelNode::generateCode (const 
OFileWriter &of) const
         {
             const char* name = attr[j];
             OUString   value = q.getValueByName( name );
-            of.writeParameter("continuous", name, value, 
sal::static_int_cast<sal_Int16>(i) );
+            of.writeOUStringLiteralParameter("continuous", name, value, 
sal::static_int_cast<sal_Int16>(i) );
         }
     }
 
@@ -2258,7 +2258,7 @@ void LCNumberingLevelNode::generateCode (const 
OFileWriter &of) const
     // generate code. (intermediate arrays)
     for( i=0; i<nStyles; i++ )
     {
-        of.writeAsciiString("\nstatic const sal_Unicode* continuousStyle" );
+        of.writeAsciiString("\nstatic constexpr rtl::OUStringConstExpr 
continuousStyle" );
         of.writeInt( sal::static_int_cast<sal_Int16>(i) );
         of.writeAsciiString("[] = {\n");
         for( sal_Int32 j=0; j<nAttributes; j++)
@@ -2269,12 +2269,12 @@ void LCNumberingLevelNode::generateCode (const 
OFileWriter &of) const
             of.writeInt(sal::static_int_cast<sal_Int16>(i));
             of.writeAsciiString(",\n");
         }
-        of.writeAsciiString("\t0\n};\n\n");
+        of.writeAsciiString("\t\n};\n\n");
     }
 
     // generate code. (top-level array)
     of.writeAsciiString("\n");
-    of.writeAsciiString("static const sal_Unicode** 
LCContinuousNumberingLevelsArray[] = {\n" );
+    of.writeAsciiString("static const rtl::OUStringConstExpr* 
LCContinuousNumberingLevelsArray[] = {\n" );
     for( i=0; i<nStyles; i++ )
     {
         of.writeAsciiString( "\t" );
@@ -2283,7 +2283,7 @@ void LCNumberingLevelNode::generateCode (const 
OFileWriter &of) const
         of.writeAsciiString( ",\n");
     }
     of.writeAsciiString("\t0\n};\n\n");
-    of.writeFunction2("getContinuousNumberingLevels_", "continuousNbOfStyles",
+    of.writeOUStringFunction2("getContinuousNumberingLevels_", 
"continuousNbOfStyles",
             "continuousNbOfAttributesPerStyle", 
"LCContinuousNumberingLevelsArray");
 }
 
diff --git a/i18npool/source/localedata/LocaleNode.hxx 
b/i18npool/source/localedata/LocaleNode.hxx
index 70995244a181..f5c9072265a3 100644
--- a/i18npool/source/localedata/LocaleNode.hxx
+++ b/i18npool/source/localedata/LocaleNode.hxx
@@ -50,7 +50,9 @@ public:
     void  writeOUStringFunction(const char *func, const char *count, const 
char *array, const char *from, const char *to) const;
     void  writeRefFunction(const char *func, std::u16string_view useLocale, 
const char *to) const;
     void  writeFunction2(const char *func, const char *style, const char* 
attr, const char *array) const;
+    void  writeOUStringFunction2(const char *func, const char *style, const 
char* attr, const char *array) const;
     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  writeRefFunction3(const char *func, std::u16string_view useLocale) 
const;
     void  writeIntParameter(const char* pAsciiStr, const sal_Int16 count, 
sal_Int16 val) const;
@@ -64,6 +66,7 @@ public:
     void  writeParameter(const char* pAsciiStr, std::u16string_view aChars, 
sal_Int16 count0, sal_Int16 count1) const;
     void  writeOUStringLiteralParameter(const char* pAsciiStr, 
std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) const;
     void  writeParameter(const char* pTagStr, const char* pAsciiStr, 
std::u16string_view aChars, const sal_Int16 count) const;
+    void  writeOUStringLiteralParameter(const char* pTagStr, const char* 
pAsciiStr, std::u16string_view aChars, const sal_Int16 count) const;
     void  writeParameter(const char* pTagStr, const char* pAsciiStr, 
std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) const;
     void  writeOUStringLiteralParameter(const char* pTagStr, const char* 
pAsciiStr, std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) 
const;
     void  closeOutput() const;
diff --git a/i18npool/source/localedata/filewriter.cxx 
b/i18npool/source/localedata/filewriter.cxx
index df7954e2fd74..a2ec7a1ea72d 100644
--- a/i18npool/source/localedata/filewriter.cxx
+++ b/i18npool/source/localedata/filewriter.cxx
@@ -141,6 +141,14 @@ void OFileWriter::writeFunction2(const char *func, const 
char *style, const char
     fprintf(m_f, "\treturn %s;\n}\n", array);
 }
 
+void OFileWriter::writeOUStringFunction2(const char *func, const char *style, 
const char* attr, const char *array) const
+{
+    fprintf(m_f, "const OUString **  SAL_CALL %s%s( sal_Int16& nStyles, 
sal_Int16& nAttributes )\n{\n", func, theLocale.c_str());
+    fprintf(m_f, "\tnStyles     = %s;\n", style);
+    fprintf(m_f, "\tnAttributes = %s;\n", attr);
+    fprintf(m_f, "\treturn (const OUString **)%s;\n}\n", array);
+}
+
 void OFileWriter::writeRefFunction2(const char *func, std::u16string_view 
useLocale) const
 {
     OString aRefLocale( OUStringToOString(useLocale, 
RTL_TEXTENCODING_ASCII_US) );
@@ -150,6 +158,15 @@ void OFileWriter::writeRefFunction2(const char *func, 
std::u16string_view useLoc
     fprintf(m_f, "\treturn %s%s(nStyles, nAttributes);\n}\n", func, locale);
 }
 
+void OFileWriter::writeOUStringRefFunction2(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& nAttributes);\n", func, locale);
+    fprintf(m_f, "const OUString **  SAL_CALL %s%s(sal_Int16& nStyles, 
sal_Int16& nAttributes)\n{\n", func, theLocale.c_str());
+    fprintf(m_f, "\treturn %s%s(nStyles, nAttributes);\n}\n", func, locale);
+}
+
 void OFileWriter::writeFunction3(const char *func, const char *style, const 
char* levels, const char* attr, const char *array) const
 {
     fprintf(m_f, "const sal_Unicode ****  SAL_CALL %s%s( sal_Int16& nStyles, 
sal_Int16& nLevels, sal_Int16& nAttributes )\n{\n", func, theLocale.c_str());
@@ -241,6 +258,13 @@ void OFileWriter::writeParameter(const char* pTagStr, 
const char* pAsciiStr, std
     fprintf(m_f, "0x0};\n");
 }
 
+void OFileWriter::writeOUStringLiteralParameter(const char* pTagStr, const 
char* pAsciiStr, std::u16string_view aChars, const sal_Int16 count) const
+{
+    fprintf(m_f, "static constexpr OUStringLiteral %s%s%d = u\"", pTagStr, 
pAsciiStr, count);
+    writeOUStringLiteralCharacters(aChars);
+    fprintf(m_f, "\";\n");
+}
+
 void OFileWriter::writeParameter(const char* pTagStr, const char* pAsciiStr, 
std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) const
 {
     fprintf(m_f, "static const sal_Unicode %s%s%d%d[] = {", pTagStr, 
pAsciiStr, count0, count1);
diff --git a/i18npool/source/localedata/localedata.cxx 
b/i18npool/source/localedata/localedata.cxx
index 89ee3d5a281d..5d7fabc727da 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -43,7 +43,7 @@ using namespace com::sun::star::lang;
 using namespace com::sun::star;
 
 typedef OUString const * (* MyFuncOUString_Type)( sal_Int16&);
-typedef sal_Unicode const *** (* MyFunc_Type2)( sal_Int16&, 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_FormatCode)( sal_Int16&, sal_Unicode const 
*&, sal_Unicode const *& );
 
@@ -1219,7 +1219,7 @@ LocaleDataImpl::getContinuousNumberingLevels( const 
lang::Locale& rLocale )
         // invoke function
         sal_Int16 nStyles;
         sal_Int16 nAttributes;
-        sal_Unicode const *** p0 = func( nStyles, nAttributes );
+        OUString const ** p0 = func( nStyles, nAttributes );
 
         // allocate memory for nAttributes attributes for each of the nStyles 
styles.
         Sequence< Sequence<beans::PropertyValue> > pv( nStyles );
@@ -1228,20 +1228,18 @@ LocaleDataImpl::getContinuousNumberingLevels( const 
lang::Locale& rLocale )
             i = Sequence<beans::PropertyValue>( nAttributes );
         }
 
-        sal_Unicode const *** pStyle = p0;
+        OUString const ** pStyle = p0;
         for( int i=0;  i<nStyles;  i++ ) {
-            sal_Unicode const ** pAttribute = pStyle[i];
+            OUString const * pAttribute = pStyle[i];
             auto pvElementRange = asNonConstRange(pvRange[i]);
             for( int j=0;  j<nAttributes;  j++ ) { // prefix, numberingtype, 
...
-                sal_Unicode const * pString = pAttribute[j];
+                OUString const & pString = pAttribute[j];
                 beans::PropertyValue& rVal = pvElementRange[j];
                 OUString sVal;
-                if( pString ) {
-                    if( 0 != j && 2 != j )
-                        sVal = pString;
-                    else if( *pString )
-                        sVal = OUString( pString, 1 );
-                }
+                if( 0 != j && 2 != j )
+                    sVal = pString;
+                else if( !pString.isEmpty() )
+                    sVal = pString.copy( 0, 1 );
 
                 switch( j )
                 {

Reply via email to