sw/source/core/text/txtfld.cxx |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 7e3b3a9bd5370c68877d7d6abe97043460a687ca
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jul 29 12:29:44 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Jul 29 13:21:18 2022 +0200

    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 <noel.gran...@collabora.co.uk>

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;

Reply via email to