From 7e3b3a9bd5370c68877d7d6abe97043460a687ca Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 29 Jul 2022 12:29:44 +0200 Subject: tdf#119840 make this loop a little more efficient by breaking out early Change-Id: I2444c9f8b79e0b517eb3ab3b19fed2d98c52a8e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137615 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/text/txtfld.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index d258127f0701..9aa36c0c86d3 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -553,16 +553,21 @@ static const SwRangeRedline* lcl_GetRedlineAtNodeInsertionOrDeletion( const SwTe for( ; nRedlPos < rTable.size() ; ++nRedlPos ) { const SwRangeRedline* pTmp = rTable[ nRedlPos ]; + SwNodeOffset nStart = pTmp->GetPoint()->nNode.GetIndex(), + nEnd = pTmp->GetMark()->nNode.GetIndex(); + if( nStart > nEnd ) + std::swap(nStart, nEnd); if( RedlineType::Delete == pTmp->GetType() || RedlineType::Insert == pTmp->GetType() ) { - auto [pRStt, pREnd ]= pTmp->StartEnd(); // SwPosition* - if( pRStt->nNode <= nNdIdx && pREnd->nNode > nNdIdx ) + if( nStart <= nNdIdx && nEnd > nNdIdx ) { bIsMoved = pTmp->IsMoved(); return pTmp; } } + if( nStart > nNdIdx ) + break; } } return nullptr; -- cgit v1.2.3