Use optimized OString concatenation
Change-Id: I7c74e007cb382701c3d9c41f9a6fb76ff0cb19fe Reviewed-on: https://gerrit.libreoffice.org/68120 Tested-by: Jenkins Reviewed-by: Matteo Casalin <matteo.casalin@yahoo.com>
This commit is contained in:
@@ -261,12 +261,8 @@ void XRMResParser::Execute( int nToken, char * pToken )
|
|||||||
|
|
||||||
OString XRMResParser::GetAttribute( const OString &rToken, const OString &rAttribute )
|
OString XRMResParser::GetAttribute( const OString &rToken, const OString &rAttribute )
|
||||||
{
|
{
|
||||||
OString sTmp( rToken );
|
const OString sSearch{ " " + rAttribute + "=" };
|
||||||
sTmp = sTmp.replace('\t', ' ');
|
OString sTmp{ rToken.replace('\t', ' ') };
|
||||||
|
|
||||||
OString sSearch( " " );
|
|
||||||
sSearch += rAttribute;
|
|
||||||
sSearch += "=";
|
|
||||||
sal_Int32 nPos = sTmp.indexOf( sSearch );
|
sal_Int32 nPos = sTmp.indexOf( sSearch );
|
||||||
|
|
||||||
if ( nPos<0 )
|
if ( nPos<0 )
|
||||||
@@ -293,9 +289,7 @@ XRMResExport::XRMResExport(
|
|||||||
pOutputStream.open( rOutputFile, PoOfstream::APP );
|
pOutputStream.open( rOutputFile, PoOfstream::APP );
|
||||||
if (!pOutputStream.isOpen())
|
if (!pOutputStream.isOpen())
|
||||||
{
|
{
|
||||||
OString sError( "Unable to open output file: " );
|
Error( "Unable to open output file: " + rOutputFile );
|
||||||
sError += rOutputFile;
|
|
||||||
Error( sError );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,9 +304,8 @@ void XRMResExport::WorkOnDesc(
|
|||||||
const OString &rOpenTag,
|
const OString &rOpenTag,
|
||||||
OString &rText )
|
OString &rText )
|
||||||
{
|
{
|
||||||
OString sDescFileName(
|
const OString sDescFileName{ sInputFileName.replaceAll("description.xml", OString())
|
||||||
sInputFileName.replaceAll("description.xml", OString()));
|
+ GetAttribute( rOpenTag, "xlink:href" ) };
|
||||||
sDescFileName += GetAttribute( rOpenTag, "xlink:href" );
|
|
||||||
ifstream file (sDescFileName.getStr(), ios::in|ios::binary|ios::ate);
|
ifstream file (sDescFileName.getStr(), ios::in|ios::binary|ios::ate);
|
||||||
if (file.is_open()) {
|
if (file.is_open()) {
|
||||||
int size = static_cast<int>(file.tellg());
|
int size = static_cast<int>(file.tellg());
|
||||||
@@ -377,9 +370,7 @@ XRMResMerge::XRMResMerge(
|
|||||||
pOutputStream.open(
|
pOutputStream.open(
|
||||||
rOutputFile.getStr(), std::ios_base::out | std::ios_base::trunc);
|
rOutputFile.getStr(), std::ios_base::out | std::ios_base::trunc);
|
||||||
if (!pOutputStream.is_open()) {
|
if (!pOutputStream.is_open()) {
|
||||||
OString sError( "Unable to open output file: " );
|
Error( "Unable to open output file: " + rOutputFile );
|
||||||
sError += rOutputFile;
|
|
||||||
Error( sError );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,10 +396,8 @@ void XRMResMerge::WorkOnDesc(
|
|||||||
( pEntrys->GetText( sText, sCur, true )) &&
|
( pEntrys->GetText( sText, sCur, true )) &&
|
||||||
!sText.isEmpty())
|
!sText.isEmpty())
|
||||||
{
|
{
|
||||||
OString sAdditionalLine( "\n " );
|
OString sAdditionalLine{ "\n " + rOpenTag };
|
||||||
sAdditionalLine += rOpenTag;
|
OString sSearch{ sLangAttribute + "=\"" };
|
||||||
OString sSearch = sLangAttribute;
|
|
||||||
sSearch += "=\"";
|
|
||||||
OString sReplace( sSearch );
|
OString sReplace( sSearch );
|
||||||
|
|
||||||
sSearch += GetAttribute( rOpenTag, sLangAttribute );
|
sSearch += GetAttribute( rOpenTag, sLangAttribute );
|
||||||
@@ -419,9 +408,7 @@ void XRMResMerge::WorkOnDesc(
|
|||||||
sSearch = OString("xlink:href=\"");
|
sSearch = OString("xlink:href=\"");
|
||||||
sReplace = sSearch;
|
sReplace = sSearch;
|
||||||
|
|
||||||
OString sLocDescFilename = sDescFilename;
|
const OString sLocDescFilename = sDescFilename.replaceFirst( "en-US", sCur);
|
||||||
sLocDescFilename = sLocDescFilename.replaceFirst(
|
|
||||||
"en-US", sCur);
|
|
||||||
|
|
||||||
sSearch += sDescFilename;
|
sSearch += sDescFilename;
|
||||||
sReplace += sLocDescFilename;
|
sReplace += sLocDescFilename;
|
||||||
@@ -491,20 +478,15 @@ void XRMResMerge::EndOfText(
|
|||||||
helper::isWellFormedXML( sContent ))
|
helper::isWellFormedXML( sContent ))
|
||||||
{
|
{
|
||||||
const OString& sText( sContent );
|
const OString& sText( sContent );
|
||||||
OString sAdditionalLine( "\n " );
|
OString sAdditionalLine{ "\n " + rOpenTag };
|
||||||
sAdditionalLine += rOpenTag;
|
OString sSearch{ sLangAttribute + "=\"" };
|
||||||
OString sSearch = sLangAttribute;
|
|
||||||
sSearch += "=\"";
|
|
||||||
OString sReplace( sSearch );
|
OString sReplace( sSearch );
|
||||||
|
|
||||||
sSearch += GetAttribute( rOpenTag, sLangAttribute );
|
sSearch += GetAttribute( rOpenTag, sLangAttribute );
|
||||||
sReplace += sCur;
|
sReplace += sCur;
|
||||||
|
|
||||||
sAdditionalLine = sAdditionalLine.replaceFirst(
|
sAdditionalLine = sAdditionalLine.replaceFirst(
|
||||||
sSearch, sReplace);
|
sSearch, sReplace) + sText + rCloseTag;
|
||||||
|
|
||||||
sAdditionalLine += sText;
|
|
||||||
sAdditionalLine += rCloseTag;
|
|
||||||
|
|
||||||
Output( sAdditionalLine );
|
Output( sAdditionalLine );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user