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 --- editeng/source/editeng/editdoc.cxx | 2 +- editeng/source/misc/svxacorr.cxx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'editeng') diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 373ee7b5158a..76fd0a4d6f01 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -1647,7 +1647,7 @@ OUString ContentNode::GetExpandedText(sal_Int32 nStartPos, sal_Int32 nEndPos) co DBG_ASSERT( nEnd >= nIndex, "End in front of the index?" ); //!! beware of sub string length of -1 if (nEnd > nIndex) - aStr.append( GetString().copy(nIndex, nEnd - nIndex) ); + aStr.appendCopy( GetString(), nIndex, nEnd - nIndex ); if ( pNextFeature ) { diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 2166d323a082..3029101da61d 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -2805,11 +2805,12 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p nTmp++; if (nTmp < nSttWdPos) break; // word delimiter found - buf.append(rTxt.copy(nFndPos, nSttWdPos - nFndPos)).append(pFnd->GetLong()); + buf.appendCopy(rTxt, nFndPos, nSttWdPos - nFndPos).append(pFnd->GetLong()); nFndPos = nSttWdPos + sTmp.getLength(); } } while (nSttWdPos != -1); - if (nEndPos - nFndPos > extra_repl) buf.append(rTxt.copy(nFndPos, nEndPos - nFndPos)); + if (nEndPos - nFndPos > extra_repl) + buf.appendCopy(rTxt, nFndPos, nEndPos - nFndPos); aLong = buf.makeStringAndClear(); } SvxAutocorrWord* pNew = new SvxAutocorrWord(aShort, aLong); -- cgit