sw/source/core/crsr/crsrsh.cxx |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

New commits:
commit d0760109b7bb965187243cdb1d3a07df83039db1
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Sep 15 10:28:48 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Sep 15 11:55:22 2022 +0200

    Only check second time when needed
    
    Change-Id: I28316a33fab208ddea2dda9f6ef3a22a8dc60457
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139969
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index c734318491c8..2a461c006666 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3639,15 +3639,17 @@ void SwCursorShell::ClearUpCursors()
         const SwNode* pStart = lcl_NodeContext( 
pStartCursor->GetPoint()->GetNode() );
         SwNodeIndex aIdx( pStartCursor->GetPoint()->GetNode() );
         SwNode * pNode = SwNodes::GoPrevious(&aIdx);
-        if( pNode == nullptr || lcl_NodeContext( *pNode ) != pStart )
-            pNode = aNodes.GoNext( &aIdx );
         if( pNode == nullptr || lcl_NodeContext( *pNode ) != pStart )
         {
-            // If the start entry of the ring is invalid replace it with a
-            // cursor pointing to the beginning of the first content node in 
the
-            // document.
-            aIdx = *(aNodes.GetEndOfContent().StartOfSectionNode());
             pNode = aNodes.GoNext( &aIdx );
+            if( pNode == nullptr || lcl_NodeContext( *pNode ) != pStart )
+            {
+                // If the start entry of the ring is invalid replace it with a
+                // cursor pointing to the beginning of the first content node 
in the
+                // document.
+                aIdx = *(aNodes.GetEndOfContent().StartOfSectionNode());
+                pNode = aNodes.GoNext( &aIdx );
+            }
         }
         bool bFound = (pNode != nullptr);
 

Reply via email to