[Libreoffice-commits] core.git: l10ntools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Mar 20 06:35:38 UTC 2019


 l10ntools/source/cfgmerge.cxx |   41 ++++++++++-------------------------------
 1 file changed, 10 insertions(+), 31 deletions(-)

New commits:
commit e99fafa6d18fb56036b2c5d739b7c0a5dd915d41
Author:     Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sat Feb 23 18:02:19 2019 +0100
Commit:     Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Wed Mar 20 07:35:14 2019 +0100

    Reduce OString operations
    
    Change-Id: I13291ca27574d3536e55d8207a0b13b2694385be
    Reviewed-on: https://gerrit.libreoffice.org/69233
    Tested-by: Jenkins
    Reviewed-by: Matteo Casalin <matteo.casalin at yahoo.com>

diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx
index 0c1167da1a3b..755359b1fa24 100644
--- a/l10ntools/source/cfgmerge.cxx
+++ b/l10ntools/source/cfgmerge.cxx
@@ -259,10 +259,7 @@ void CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
             }
             else
             {
-                OString sError( "Misplaced close tag: " );
-                sError += sToken;
-                sError += " in file ";
-                sError += global::inputPathname;
+                const OString sError{ "Misplaced close tag: " + sToken + " in file " + global::inputPathname };
                 yyerror(sError.getStr());
                 std::exit(EXIT_FAILURE);
             }
@@ -470,34 +467,16 @@ void CfgMerge::WorkOnResourceEnd()
                 if (
                     ( !sCur.equalsIgnoreAsciiCase("en-US") ) && !sContent.isEmpty())
                 {
-
-                    OString sText = helper::QuotHTML( sContent);
-
-                    OString sAdditionalLine( "\t" );
-
                     OString sTextTag = pStackData->sTextTag;
-                    OString sTemp = sTextTag.copy( sTextTag.indexOf( "xml:lang=" ));
-
-                    sal_Int32 n = 0;
-                    OString sSearch = sTemp.getToken(0, '"', n);
-                    sSearch += "\"";
-                    sSearch += sTemp.getToken(0, '"', n);
-                    sSearch += "\"";
-
-                    OString sReplace = sTemp.getToken(0, '"');
-                    sReplace += "\"";
-                    sReplace += sCur;
-                    sReplace += "\"";
-
-                    sTextTag = sTextTag.replaceFirst(sSearch, sReplace);
-
-                    sAdditionalLine += sTextTag;
-                    sAdditionalLine += sText;
-                    sAdditionalLine += pStackData->sEndTextTag;
-
-                    sAdditionalLine += "\n";
-                    sAdditionalLine += sLastWhitespace;
-
+                    const sal_Int32 nLangAttributeStart{ sTextTag.indexOf( "xml:lang=" ) };
+                    const sal_Int32 nLangStart{ sTextTag.indexOf( '"', nLangAttributeStart )+1 };
+                    const sal_Int32 nLangEnd{ sTextTag.indexOf( '"', nLangStart ) };
+                    OString sAdditionalLine{ "\t"
+                        + sTextTag.replaceAt(nLangStart, nLangEnd-nLangStart, sCur)
+                        + helper::QuotHTML(sContent)
+                        + pStackData->sEndTextTag
+                        + "\n"
+                        + sLastWhitespace };
                     Output( sAdditionalLine );
                 }
             }


More information about the Libreoffice-commits mailing list