summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-18 09:46:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-18 11:18:48 +0100
commitfbb41798b86c5ed35eb80aa07a5ee7c9866ac4e8 (patch)
tree8237d08811d1cdebdc1f8c138ce56aeea67f943e /sc
parent6b768542ddd52573bbdb0e7b5b85ce5a9dd4551d (diff)
tdf#133603 remove some string copying
Change-Id: I5b9f011d276ec30a50648e7984862b9e5f4b5577 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131729 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/excel/xechart.cxx4
-rw-r--r--sc/source/filter/excel/xecontent.cxx2
-rw-r--r--sc/source/filter/excel/xehelper.cxx6
-rw-r--r--sc/source/filter/excel/xestring.cxx23
-rw-r--r--sc/source/filter/inc/xechart.hxx2
-rw-r--r--sc/source/filter/inc/xehelper.hxx2
-rw-r--r--sc/source/filter/inc/xestring.hxx12
7 files changed, 24 insertions, 27 deletions
diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index dd82fe980dc9..f42a1448e54e 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -989,7 +989,7 @@ sal_uInt16 XclExpChSourceLink::ConvertStringSequence( const Sequence< Reference<
// Excel start position of this portion
sal_uInt16 nXclPortionStart = mxString->Len();
// add portion text to Excel string
- XclExpStringHelper::AppendString( *mxString, GetRoot(), aText.copy( nPortionPos, nPortionEnd - nPortionPos ) );
+ XclExpStringHelper::AppendString( *mxString, GetRoot(), aText.subView( nPortionPos, nPortionEnd - nPortionPos ) );
if( nXclPortionStart < mxString->Len() )
{
// find font index variable dependent on script type
@@ -1039,7 +1039,7 @@ void XclExpChSourceLink::ConvertNumFmt( const ScfPropertySet& rPropSet, bool bPe
}
}
-void XclExpChSourceLink::AppendString( const OUString& rStr )
+void XclExpChSourceLink::AppendString( std::u16string_view rStr )
{
if (!mxString)
return;
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index fbeedbcaa80b..cde4344b50e5 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1774,7 +1774,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle ) :
sFormulaBuf.append( aToken );
if (nStringIx<0)
break;
- mxString1->Append(OUString(u'\0'));
+ mxString1->Append(u"\0");
sFormulaBuf.append( ',' );
sListBuf.append( ',' );
}
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index aeed23121e35..d45bf0c2cf6a 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -387,7 +387,7 @@ XclExpStringRef lclCreateFormattedString(
// Excel start position of this portion
sal_Int32 nXclPortionStart = xString->Len();
// add portion text to Excel string
- XclExpStringHelper::AppendString( *xString, rRoot, rText.copy( nPortionPos, nPortionEnd - nPortionPos ) );
+ XclExpStringHelper::AppendString( *xString, rRoot, rText.subView( nPortionPos, nPortionEnd - nPortionPos ) );
if( nXclPortionStart < xString->Len() )
{
// insert font into buffer
@@ -541,7 +541,7 @@ XclExpStringRef XclExpStringHelper::CreateString(
return xString;
}
-void XclExpStringHelper::AppendString( XclExpString& rXclString, const XclExpRoot& rRoot, const OUString& rString )
+void XclExpStringHelper::AppendString( XclExpString& rXclString, const XclExpRoot& rRoot, std::u16string_view rString )
{
if( rRoot.GetBiff() == EXC_BIFF8 )
rXclString.Append( rString );
@@ -552,7 +552,7 @@ void XclExpStringHelper::AppendString( XclExpString& rXclString, const XclExpRoo
void XclExpStringHelper::AppendChar( XclExpString& rXclString, const XclExpRoot& rRoot, sal_Unicode cChar )
{
if( rRoot.GetBiff() == EXC_BIFF8 )
- rXclString.Append( OUString(cChar) );
+ rXclString.Append( rtl::OUStringChar(cChar) );
else
rXclString.AppendByte( cChar, rRoot.GetTextEncoding() );
}
diff --git a/sc/source/filter/excel/xestring.cxx b/sc/source/filter/excel/xestring.cxx
index db85728ef7ef..cb76518e6b41 100644
--- a/sc/source/filter/excel/xestring.cxx
+++ b/sc/source/filter/excel/xestring.cxx
@@ -129,9 +129,9 @@ void XclExpString::AssignByte(
// append ---------------------------------------------------------------------
-void XclExpString::Append( const OUString& rString )
+void XclExpString::Append( std::u16string_view rString )
{
- BuildAppend( rString.getStr(), rString.getLength() );
+ BuildAppend( rString );
}
void XclExpString::AppendByte( std::u16string_view rString, rtl_TextEncoding eTextEnc )
@@ -140,7 +140,7 @@ void XclExpString::AppendByte( std::u16string_view rString, rtl_TextEncoding eTe
{
// length may differ from length of rString
OString aByteStr(OUStringToOString(rString, eTextEnc));
- BuildAppend(aByteStr.getStr(), aByteStr.getLength());
+ BuildAppend(aByteStr);
}
}
@@ -148,13 +148,12 @@ void XclExpString::AppendByte( sal_Unicode cChar, rtl_TextEncoding eTextEnc )
{
if( !cChar )
{
- char cByteChar = 0;
- BuildAppend( &cByteChar, 1 );
+ BuildAppend( "\0" );
}
else
{
OString aByteStr( &cChar, 1, eTextEnc ); // length may be >1
- BuildAppend( aByteStr.getStr(), aByteStr.getLength() );
+ BuildAppend( aByteStr );
}
}
@@ -535,25 +534,25 @@ void XclExpString::InitAppend( sal_Int32 nAddLen )
maCharBuffer.resize( mnLen );
}
-void XclExpString::BuildAppend( const sal_Unicode* pcSource, sal_Int32 nAddLen )
+void XclExpString::BuildAppend( std::u16string_view rSource )
{
OSL_ENSURE( mbIsBiff8, "XclExpString::BuildAppend - must not be called at byte strings" );
if( mbIsBiff8 )
{
sal_uInt16 nOldLen = mnLen;
- InitAppend( nAddLen );
- CharsToBuffer( pcSource, nOldLen, mnLen - nOldLen );
+ InitAppend( rSource.size() );
+ CharsToBuffer( rSource.data(), nOldLen, mnLen - nOldLen );
}
}
-void XclExpString::BuildAppend( const char* pcSource, sal_Int32 nAddLen )
+void XclExpString::BuildAppend( std::string_view rSource )
{
OSL_ENSURE( !mbIsBiff8, "XclExpString::BuildAppend - must not be called at unicode strings" );
if( !mbIsBiff8 )
{
sal_uInt16 nOldLen = mnLen;
- InitAppend( nAddLen );
- CharsToBuffer( pcSource, nOldLen, mnLen - nOldLen );
+ InitAppend( rSource.size() );
+ CharsToBuffer( rSource.data(), nOldLen, mnLen - nOldLen );
}
}
diff --git a/sc/source/filter/inc/xechart.hxx b/sc/source/filter/inc/xechart.hxx
index bd6230f2d68a..d291266a06b1 100644
--- a/sc/source/filter/inc/xechart.hxx
+++ b/sc/source/filter/inc/xechart.hxx
@@ -400,7 +400,7 @@ public:
/** Converts the number format from the passed property set. */
void ConvertNumFmt( const ScfPropertySet& rPropSet, bool bPercent );
- void AppendString( const OUString& rStr );
+ void AppendString( std::u16string_view rStr );
/** Returns true, if this source link contains explicit string data. */
bool HasString() const { return mxString && !mxString->IsEmpty(); }
diff --git a/sc/source/filter/inc/xehelper.hxx b/sc/source/filter/inc/xehelper.hxx
index 8b6b0014a080..b608f65b3ea3 100644
--- a/sc/source/filter/inc/xehelper.hxx
+++ b/sc/source/filter/inc/xehelper.hxx
@@ -256,7 +256,7 @@ public:
static void AppendString(
XclExpString& rXclString,
const XclExpRoot& rRoot,
- const OUString& rString );
+ std::u16string_view rString);
/** Appends a character to an Excel string object.
@descr Selects the correct Append() function depending on the current
diff --git a/sc/source/filter/inc/xestring.hxx b/sc/source/filter/inc/xestring.hxx
index a5980f53b4c4..a61e563f01b9 100644
--- a/sc/source/filter/inc/xestring.hxx
+++ b/sc/source/filter/inc/xestring.hxx
@@ -90,7 +90,7 @@ public:
/** Appends a string. Uses the string flags used in constructor or last Assign().
@descr This object must be a BIFF8 Unicode string. */
- void Append( const OUString& rString );
+ void Append( std::u16string_view rString );
/** Appends a string. Uses the string flags used in constructor or last Assign().
@descr This object must be a BIFF2-BIFF7 byte string. */
@@ -216,13 +216,11 @@ private:
@param nAddLen The number of characters to be appended. */
void InitAppend( sal_Int32 nAddLen );
/** Appends the given Unicode array to the character buffer.
- @param pcSource The source character buffer. Trailing NUL character is not necessary.
- @param nAddLen The real count of characters contained in the passed buffer. */
- void BuildAppend( const sal_Unicode* pcSource, sal_Int32 nAddLen );
+ @param pcSource The source character buffer. Trailing NUL character is not necessary. */
+ void BuildAppend( std::u16string_view );
/** Appends the given character array to the character buffer.
- @param pcSource The source character buffer. Trailing NUL character is not necessary.
- @param nAddLen The real count of characters contained in the passed buffer. */
- void BuildAppend( const char* pcSource, sal_Int32 nAddLen );
+ @param pcSource The source character buffer. Trailing NUL character is not necessary. */
+ void BuildAppend( std::string_view );
/** Initializes write process on stream. */
void PrepareWrite( XclExpStream& rStrm, sal_uInt16 nBytes ) const;