sw/source/core/doc/docredln.cxx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
New commits: commit 941d03968cc12a6f7badc2641decd91dbd8f0244 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue May 28 15:26:19 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed May 29 18:19:23 2024 +0200 simplify and reduce allocation in SwRedlineTable::getTextOfArea Change-Id: Iea119c61aef1c5459c8c9d00c6e1c7de93ec29c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168156 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index b5a9059a579d..9860964a89d6 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -872,33 +872,29 @@ OUString SwRedlineTable::getTextOfArea(size_type rPosStart, size_type rPosEnd) c SwRangeRedline* pRedline = (*this)[nIdx]; bool bStartWithNonTextNode = false; - SwPaM *pPaM; - bool bDeletePaM = false; + OUString sNew; if (nullptr == pRedline->GetContentIdx()) { - pPaM = pRedline; + sNew = pRedline->GetText(); } else // otherwise it is saved in pContentSect, e.g. during ODT import { - pPaM = new SwPaM(pRedline->GetContentIdx()->GetNode(), + SwPaM aTmpPaM(pRedline->GetContentIdx()->GetNode(), *pRedline->GetContentIdx()->GetNode().EndOfSectionNode()); - if (!pPaM->Start()->nNode.GetNode().GetTextNode()) + if (!aTmpPaM.Start()->nNode.GetNode().GetTextNode()) { bStartWithNonTextNode = true; } - bDeletePaM = true; + sNew = aTmpPaM.GetText(); } - const OUString sNew = pPaM->GetText(); if (bStartWithNonTextNode && sNew[0] == CH_TXTATR_NEWLINE) { - sRet += pPaM->GetText().subView(1); + sRet += sNew.subView(1); } else - sRet += pPaM->GetText(); - if (bDeletePaM) - delete pPaM; + sRet += sNew; } return sRet;