diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-03-27 14:52:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-03 09:26:35 +0200 |
commit | 8cfa7f4dc00f3dd37e57917ef25c806b0e9e6e73 (patch) | |
tree | 35408cf40d7bf3f93ff7405695f48796abc6089b | |
parent | 93f1c3665fcdc31c36078f179ac37fd69d3ebb00 (diff) |
add more append methods to *StringBuffer
which performs the append without needing the creation of a temporary
*String
Change-Id: If9ad3222275f26659db2e7df8d34f068977c4d17
Reviewed-on: https://gerrit.libreoffice.org/69826
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | bridges/source/cpp_uno/msvc_win32_intel/except.cxx | 4 | ||||
-rw-r--r-- | bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx | 4 | ||||
-rw-r--r-- | include/rtl/strbuf.hxx | 20 | ||||
-rw-r--r-- | include/rtl/ustrbuf.hxx | 20 | ||||
-rw-r--r-- | l10ntools/source/helper.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/dif/difimp.cxx | 4 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ascii/ascatr.cxx | 4 | ||||
-rw-r--r-- | tools/source/inet/inetmime.cxx | 12 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumfi.cxx | 4 |
11 files changed, 60 insertions, 20 deletions
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/except.cxx b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx index 4f761ef3ed20..9f7bc81d71d1 100644 --- a/bridges/source/cpp_uno/msvc_win32_intel/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx @@ -52,7 +52,7 @@ static inline OUString toUNOname( OUString const & rRTTIname ) throw () while (nPos > 0) { sal_Int32 n = aStr.lastIndexOf( '@', nPos ); - aRet.append( aStr.copy( n +1, nPos -n -1 ) ); + aRet.append( aStr, n +1, nPos -n -1 ); if (n >= 0) { aRet.append( '.' ); @@ -70,7 +70,7 @@ static inline OUString toRTTIname( OUString const & rUNOname ) throw () while (nPos > 0) { sal_Int32 n = rUNOname.lastIndexOf( '.', nPos ); - aRet.append( rUNOname.copy( n +1, nPos -n -1 ) ); + aRet.append( rUNOname, n +1, nPos -n -1 ); aRet.append( '@' ); nPos = n; } diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx index 385f5f5cb9ed..0961f618aada 100644 --- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx @@ -275,7 +275,7 @@ static OUString toUNOname( while (nPos > 0) { sal_Int32 n = aStr.lastIndexOf( '@', nPos ); - aRet.append( aStr.copy( n +1, nPos -n -1 ) ); + aRet.append( aStr, n +1, nPos -n -1 ); if (n >= 0) { aRet.append( '.' ); @@ -295,7 +295,7 @@ static OUString toRTTIname( while (nPos > 0) { sal_Int32 n = rUNOname.lastIndexOf( '.', nPos ); - aRet.append( rUNOname.copy( n +1, nPos -n -1 ) ); + aRet.append( rUNOname, n +1, nPos -n -1 ); aRet.append( '@' ); nPos = n; } diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx index c674f34d997c..81100919353b 100644 --- a/include/rtl/strbuf.hxx +++ b/include/rtl/strbuf.hxx @@ -482,6 +482,26 @@ public: } /** + Appends a portion of the string to this string buffer. + + The characters of the <code>OUString</code> argument are appended, in + order, to the contents of this string buffer, increasing the + length of this string buffer by the length of the argument. + + @param str a string. + @param beginIndex the beginning index, inclusive. + @param count the number of characters. + @return this string buffer. + @since Libreoffice 6.4 + */ + OStringBuffer & append(const OString &str, sal_Int32 beginIndex, sal_Int32 count) + { + assert( count == 0 || (beginIndex >= 0 && beginIndex < str.getLength()) ); + assert( beginIndex <= str.getLength() - count ); + return append( str.getStr() + beginIndex, count ); + } + + /** Appends the string representation of the <code>char</code> array argument to this string buffer. diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx index 62ba9f6b2cd7..9f3c8d1650ff 100644 --- a/include/rtl/ustrbuf.hxx +++ b/include/rtl/ustrbuf.hxx @@ -536,6 +536,26 @@ public: return append( str.getStr(), str.getLength() ); } + /** + Appends a portion of the string to this string buffer. + + The characters of the <code>OUString</code> argument are appended, in + order, to the contents of this string buffer, increasing the + length of this string buffer by the length of the argument. + + @param str a string. + @param beginIndex the beginning index, inclusive. + @param count the number of characters. + @return this string buffer. + @since Libreoffice 6.4 + */ + OUStringBuffer & append(const OUString &str, sal_Int32 beginIndex, sal_Int32 count) + { + assert( count == 0 || (beginIndex >= 0 && beginIndex < str.getLength()) ); + assert( beginIndex <= str.getLength() - count ); + return append( str.getStr() + beginIndex, count ); + } + #if defined LIBO_INTERNAL_ONLY OUStringBuffer & append(std::u16string_view sv) { if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) { diff --git a/l10ntools/source/helper.cxx b/l10ntools/source/helper.cxx index c16d104b34e9..ba1598de2452 100644 --- a/l10ntools/source/helper.cxx +++ b/l10ntools/source/helper.cxx @@ -21,7 +21,7 @@ OString escapeAll( sal_Int32 nUnEscapedOne = rUnEscaped.indexOf(rText[nIndex]); if( nUnEscapedOne != -1 ) { - sReturn.append(rEscaped.copy(nUnEscapedOne*2,2)); + sReturn.append(rEscaped, nUnEscapedOne*2, 2); } else sReturn.append(rText[nIndex]); diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx index 4040f4adb67e..09121ed7c5fc 100644 --- a/sc/source/filter/dif/difimp.cxx +++ b/sc/source/filter/dif/difimp.cxx @@ -357,7 +357,7 @@ TOPIC DifParser::GetNextTopic() OSL_ENSURE( aLine.getLength() >= 2, "+GetNextTopic(): <String> is too short!" ); if( aLine.getLength() > 2 ) - m_aData.append(aLine.copy(1, aLine.getLength() - 2)); + m_aData.append(aLine, 1, aLine.getLength() - 2); else m_aData.truncate(); eS = S_END; @@ -556,7 +556,7 @@ DATASET DifParser::GetNextDataset() } else if( pLine[nLineLength - 1] == '"' ) { - m_aData.append(aLine.copy(0, nLineLength -1)); + m_aData.append(aLine, 0, nLineLength -1); lcl_DeEscapeQuotesDif(m_aData); eRet = D_STRING; } diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index daa9791dba3c..c7d6954995d6 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -1969,7 +1969,7 @@ OUString SvNumberformat::StripNewCurrencyDelimiters( const OUString& rStr ) sal_Int32 nEnd; if ( (nEnd = GetQuoteEnd( rStr, nPos )) >= 0 ) { - aTmp.append(rStr.copy( nStartPos, ++nEnd - nStartPos )); + aTmp.append(rStr, nStartPos, ++nEnd - nStartPos ); nStartPos = nEnd; } else diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx index ddcc22637923..91507a698928 100644 --- a/sw/source/filter/ascii/ascatr.cxx +++ b/sw/source/filter/ascii/ascatr.cxx @@ -312,14 +312,14 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode ) { if (nNextAttr <= curRedline.first) { - buf.append(aStr.copy(nStrPos, nNextAttr - nStrPos)); + buf.append(aStr, nStrPos, nNextAttr - nStrPos); break; } else if (nStrPos < curRedline.second) { if (nStrPos < curRedline.first) { - buf.append(aStr.copy(nStrPos, curRedline.first - nStrPos)); + buf.append(aStr, nStrPos, curRedline.first - nStrPos); } if (curRedline.second <= nNextAttr) { diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx index decd1041a547..9a8b463783ba 100644 --- a/tools/source/inet/inetmime.cxx +++ b/tools/source/inet/inetmime.cxx @@ -1350,9 +1350,9 @@ OUString INetMIME::decodeHeaderFieldBody(const OString& rBody) bDone = true; break; } - sText.append(rBody.copy( + sText.append(rBody, (pEncodedTextCopyBegin - pBegin), - (q - 1 - pEncodedTextCopyBegin))); + (q - 1 - pEncodedTextCopyBegin)); sText.append(sal_Char(nDigit1 << 4 | nDigit2)); q += 2; pEncodedTextCopyBegin = q; @@ -1361,18 +1361,18 @@ OUString INetMIME::decodeHeaderFieldBody(const OString& rBody) case '?': if (q - pEncodedTextBegin > 1) - sText.append(rBody.copy( + sText.append(rBody, (pEncodedTextCopyBegin - pBegin), - (q - 1 - pEncodedTextCopyBegin))); + (q - 1 - pEncodedTextCopyBegin)); else bEncodedWord = false; bDone = true; break; case '_': - sText.append(rBody.copy( + sText.append(rBody, (pEncodedTextCopyBegin - pBegin), - (q - 1 - pEncodedTextCopyBegin))); + (q - 1 - pEncodedTextCopyBegin)); sText.append(' '); pEncodedTextCopyBegin = q; break; diff --git a/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx b/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx index 531ab229f976..67020fa20272 100644 --- a/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx +++ b/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx @@ -64,12 +64,12 @@ namespace inXML[ end - 1 ] == '/' ) { // copy from original buffer - preserve case. - buf.append( in.copy( start, end - start ) ); + buf.append( in, start, end - start ); } else { // copy from original buffer - preserve case. - buf.append( in.copy( start, end - start + 4 ) ); + buf.append( in, start, end - start + 4 ); } start = end + 4; end = inXML.indexOf( "dav:", start ); diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index 1a7b81c6f311..38530e1a6946 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -2018,9 +2018,9 @@ void SvXMLNumFormatContext::AddCurrency( const OUString& rContent, LanguageType // remove both quotes from aFormatCode OUString aOld = aFormatCode.makeStringAndClear(); if ( nFirst > 0 ) - aFormatCode.append( aOld.copy( 0, nFirst ) ); + aFormatCode.append( aOld, 0, nFirst ); if ( nLength > nFirst + 2 ) - aFormatCode.append( aOld.copy( nFirst + 1, nLength - nFirst - 2 ) ); + aFormatCode.append( aOld, nFirst + 1, nLength - nFirst - 2 ); } } } |