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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 5 21:30:35 UTC 2019


 l10ntools/source/xrmmerge.cxx |   42 ++++++++++++------------------------------
 1 file changed, 12 insertions(+), 30 deletions(-)

New commits:
commit c7ab0bff8df23661ee9304578bd9fcf63f4d2dd0
Author:     Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Feb 17 23:44:17 2019 +0100
Commit:     Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Tue Mar 5 22:30:09 2019 +0100

    Use optimized OString concatenation
    
    Change-Id: I7c74e007cb382701c3d9c41f9a6fb76ff0cb19fe
    Reviewed-on: https://gerrit.libreoffice.org/68120
    Tested-by: Jenkins
    Reviewed-by: Matteo Casalin <matteo.casalin at yahoo.com>

diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index b6f7d388c31f..26dee6f4540c 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -261,12 +261,8 @@ void XRMResParser::Execute( int nToken, char * pToken )
 
 OString XRMResParser::GetAttribute( const OString &rToken, const OString &rAttribute )
 {
-    OString sTmp( rToken );
-    sTmp = sTmp.replace('\t', ' ');
-
-    OString sSearch( " " );
-    sSearch += rAttribute;
-    sSearch += "=";
+    const OString sSearch{ " " + rAttribute + "=" };
+    OString sTmp{ rToken.replace('\t', ' ') };
     sal_Int32 nPos = sTmp.indexOf( sSearch );
 
     if ( nPos<0 )
@@ -293,9 +289,7 @@ XRMResExport::XRMResExport(
     pOutputStream.open( rOutputFile, PoOfstream::APP );
     if (!pOutputStream.isOpen())
     {
-        OString sError( "Unable to open output file: " );
-        sError += rOutputFile;
-        Error( sError );
+        Error( "Unable to open output file: " + rOutputFile );
     }
 }
 
@@ -310,9 +304,8 @@ void XRMResExport::WorkOnDesc(
     const OString &rOpenTag,
     OString &rText )
 {
-    OString sDescFileName(
-        sInputFileName.replaceAll("description.xml", OString()));
-    sDescFileName += GetAttribute( rOpenTag, "xlink:href" );
+    const OString sDescFileName{ sInputFileName.replaceAll("description.xml", OString())
+        + GetAttribute( rOpenTag, "xlink:href" ) };
     ifstream file (sDescFileName.getStr(), ios::in|ios::binary|ios::ate);
     if (file.is_open()) {
         int size = static_cast<int>(file.tellg());
@@ -377,9 +370,7 @@ XRMResMerge::XRMResMerge(
     pOutputStream.open(
         rOutputFile.getStr(), std::ios_base::out | std::ios_base::trunc);
     if (!pOutputStream.is_open()) {
-        OString sError( "Unable to open output file: " );
-        sError += rOutputFile;
-        Error( sError );
+        Error( "Unable to open output file: " + rOutputFile );
     }
 }
 
@@ -405,10 +396,8 @@ void XRMResMerge::WorkOnDesc(
                     ( pEntrys->GetText( sText, sCur, true )) &&
                     !sText.isEmpty())
                 {
-                    OString sAdditionalLine( "\n        " );
-                    sAdditionalLine += rOpenTag;
-                    OString sSearch = sLangAttribute;
-                    sSearch += "=\"";
+                    OString sAdditionalLine{ "\n        "  + rOpenTag };
+                    OString sSearch{ sLangAttribute + "=\"" };
                     OString sReplace( sSearch );
 
                     sSearch += GetAttribute( rOpenTag, sLangAttribute );
@@ -419,9 +408,7 @@ void XRMResMerge::WorkOnDesc(
                     sSearch = OString("xlink:href=\"");
                     sReplace = sSearch;
 
-                    OString sLocDescFilename = sDescFilename;
-                    sLocDescFilename = sLocDescFilename.replaceFirst(
-                        "en-US", sCur);
+                    const OString sLocDescFilename = sDescFilename.replaceFirst( "en-US", sCur);
 
                     sSearch += sDescFilename;
                     sReplace += sLocDescFilename;
@@ -491,20 +478,15 @@ void XRMResMerge::EndOfText(
                     helper::isWellFormedXML( sContent ))
                 {
                     const OString& sText( sContent );
-                    OString sAdditionalLine( "\n        " );
-                    sAdditionalLine += rOpenTag;
-                    OString sSearch = sLangAttribute;
-                    sSearch += "=\"";
+                    OString sAdditionalLine{ "\n        " + rOpenTag };
+                    OString sSearch{ sLangAttribute + "=\"" };
                     OString sReplace( sSearch );
 
                     sSearch += GetAttribute( rOpenTag, sLangAttribute );
                     sReplace += sCur;
 
                     sAdditionalLine = sAdditionalLine.replaceFirst(
-                        sSearch, sReplace);
-
-                    sAdditionalLine += sText;
-                    sAdditionalLine += rCloseTag;
+                        sSearch, sReplace) + sText + rCloseTag;
 
                     Output( sAdditionalLine );
                 }


More information about the Libreoffice-commits mailing list