From cd66852f6dd08631a25d15a1527a647e69ab8ce3 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 7 Aug 2018 10:34:54 +0200 Subject: create appendCopy method in OUStringBuffer so we can avoid temporary copies when appending a substring of an OUString to the buffer. I would have preferred to call the method just "append" but that results in ambiguous method errors when the callsite is something like sal_Int32 n; OUStringBuffer s; s.append(n, 10); I'm not sure why Change-Id: I6b5b6641fcb5b26ce2269f89ef06e03c0b6aa76f Reviewed-on: https://gerrit.libreoffice.org/58666 Tested-by: Jenkins Reviewed-by: Noel Grandin --- unotools/source/config/configpaths.cxx | 4 ++-- unotools/source/i18n/textsearch.cxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'unotools/source') diff --git a/unotools/source/config/configpaths.cxx b/unotools/source/config/configpaths.cxx index abbf8f465f09..cd2e9c7f06a7 100644 --- a/unotools/source/config/configpaths.cxx +++ b/unotools/source/config/configpaths.cxx @@ -49,7 +49,7 @@ void lcl_resolveCharEntities(OUString & aLocalString) OSL_ENSURE(ch,"Configuration path contains '&' that is not part of a valid character escape"); if (ch) { - aResult.append(aLocalString.copy(nStart,nEscapePos-nStart)).append(ch); + aResult.appendCopy(aLocalString, nStart,nEscapePos-nStart).append(ch); sal_Int32 nEscapeEnd=aLocalString.indexOf(';',nEscapePos); nStart = nEscapeEnd+1; @@ -62,7 +62,7 @@ void lcl_resolveCharEntities(OUString & aLocalString) } while ( nEscapePos > 0); - aResult.append(aLocalString.copy(nStart)); + aResult.appendCopy(aLocalString, nStart); aLocalString = aResult.makeStringAndClear(); } diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx index baddd527d2b3..5bb4dfd81a4a 100644 --- a/unotools/source/i18n/textsearch.cxx +++ b/unotools/source/i18n/textsearch.cxx @@ -306,7 +306,7 @@ void TextSearch::ReplaceBackReferences( OUString& rReplaceStr, const OUString &r { sal_Int32 nStart = rResult.startOffset[0]; sal_Int32 nLength = rResult.endOffset[0] - rResult.startOffset[0]; - sBuff.append(rStr.getStr() + nStart, nLength); + sBuff.appendCopy(rStr, nStart, nLength); } else if((i < rReplaceStr.getLength() - 1) && rReplaceStr[i] == '$') { @@ -339,7 +339,7 @@ void TextSearch::ReplaceBackReferences( OUString& rReplaceStr, const OUString &r nSttReg = rResult.endOffset[j]; } // Copy reference from found string - sBuff.append(rStr.getStr() + nSttReg, nRegLen); + sBuff.appendCopy(rStr, nSttReg, nRegLen); } i += 1; } -- cgit