sw/source/core/draw/dcontact.cxx |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit 5703d3af04b8fe78fdd4dbef14b08d8446402779
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Jan 14 12:31:48 2024 +0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Jan 14 09:59:48 2024 +0100

    Simplify a bit
    
    And avoid a second call of pObj->GetUserCall.
    
    Change-Id: I4487ad33df594a8a96b517c5b4671512dea7116d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162042
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 1afe6e5c154d..f0f8a7fd823c 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -170,12 +170,16 @@ SwRect GetBoundRectOfAnchoredObj( const SdrObject* pObj )
 /// Returns the UserCall if applicable from the group object
 SwContact* GetUserCall( const SdrObject* pObj )
 {
-    SdrObject *pTmp;
-    while ( !pObj->GetUserCall() && nullptr != (pTmp = 
pObj->getParentSdrObjectFromSdrObject()) )
-        pObj = pTmp;
-    assert((!pObj->GetUserCall() || nullptr != dynamic_cast<const 
SwContact*>(pObj->GetUserCall())) &&
-            "<::GetUserCall(..)> - wrong type of found object user call." );
-    return static_cast<SwContact*>(pObj->GetUserCall());
+    for (; pObj; pObj = pObj->getParentSdrObjectFromSdrObject())
+    {
+        if (auto pUserCall = pObj->GetUserCall())
+        {
+            assert(dynamic_cast<SwContact*>(pUserCall)
+                   && "<::GetUserCall(..)> - wrong type of found object user 
call.");
+            return static_cast<SwContact*>(pUserCall);
+        }
+    }
+    return nullptr;
 }
 
 /// Returns true if the SrdObject is a Marquee-Object (scrolling text)

Reply via email to