sd/inc/ResourceId.hxx                               |    8 -
 sd/source/ui/framework/configuration/ResourceId.cxx |   89 +-------------------
 2 files changed, 6 insertions(+), 91 deletions(-)

New commits:
commit d4cf3f20dd7493850fb8832fc4b10d66a66a7264
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Jun 25 10:28:27 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Wed Jun 25 13:59:29 2025 +0200

    inline USE_OPTIMISATIONS in ResourceId
    
    it has been true for very very long, so just make it the default
    
    Change-Id: I249d22d5cf42fce812241cba086dc6ce536a6bbd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186946
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sd/inc/ResourceId.hxx b/sd/inc/ResourceId.hxx
index b2341ba4466a..5b9be4b2f681 100644
--- a/sd/inc/ResourceId.hxx
+++ b/sd/inc/ResourceId.hxx
@@ -156,14 +156,6 @@ private:
     */
     sal_Int16 CompareToLocalImplementation (const ResourceId& rId) const;
 
-    /** Compare the called ResourceId object to the given XResourceId object
-        reference.  The comparison is done via the UNO interface.  Namely,
-        it uses the getResourceURL() and the getAnchorURLs() methods to get
-        access to the URLs of the given object.
-    */
-    sal_Int16 CompareToExternalImplementation (const css::uno::Reference<
-        css::drawing::framework::XResourceId>& rxId) const;
-
     /** Return whether the called ResourceId object is bound to the anchor
         consisting of the URLs given by psFirstAnchorURL and paAnchorURLs.
         @param psFirstAnchorURL
diff --git a/sd/source/ui/framework/configuration/ResourceId.cxx 
b/sd/source/ui/framework/configuration/ResourceId.cxx
index 5782afc41724..5f8654fad6dc 100644
--- a/sd/source/ui/framework/configuration/ResourceId.cxx
+++ b/sd/source/ui/framework/configuration/ResourceId.cxx
@@ -34,14 +34,6 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::drawing::framework;
 
-/** When the USE_OPTIMIZATIONS symbol is defined then at some optimizations
-    are activated that work only together with XResourceId objects that are
-    implemented by the ResourceId class.  For other implementations of when
-    the USE_OPTIMIZATIONS symbol is not defined then alternative code is
-    used instead.
-*/
-#define USE_OPTIMIZATIONS
-
 namespace sd::framework {
 
 //===== ResourceId ============================================================
@@ -210,22 +202,10 @@ sal_Int16 SAL_CALL
     }
     else
     {
-        ResourceId* pId = nullptr;
-#ifdef USE_OPTIMIZATIONS
-        pId = dynamic_cast<ResourceId*>(rxResourceId.get());
-#endif
-        if (pId != nullptr)
-        {
-            // We have direct access to the implementation of the given
-            // resource id object.
-            nResult = CompareToLocalImplementation(*pId);
-        }
-        else
-        {
-            // We have to do the comparison via the UNO interface of the
-            // given resource id object.
-            nResult = CompareToExternalImplementation(rxResourceId);
-        }
+        ResourceId& rId = dynamic_cast<ResourceId&>(*rxResourceId);
+        // We have direct access to the implementation of the given
+        // resource id object.
+        nResult = CompareToLocalImplementation(rId);
     }
 
     return nResult;
@@ -273,51 +253,6 @@ sal_Int16 ResourceId::CompareToLocalImplementation (const 
ResourceId& rId) const
     return nResult;
 }
 
-sal_Int16 ResourceId::CompareToExternalImplementation (const 
Reference<XResourceId>& rxId) const
-{
-    sal_Int16 nResult (0);
-
-    const Sequence<OUString> aAnchorURLs (rxId->getAnchorURLs());
-    const sal_uInt32 nLocalURLCount (maResourceURLs.size());
-    const sal_uInt32 nURLCount(1+aAnchorURLs.getLength());
-
-    // Start comparison with the top most anchors.
-    sal_Int32 nLocalResult (0);
-    for (sal_Int32 nIndex=nURLCount-1,nLocalIndex=nLocalURLCount-1;
-         nIndex>=0&&nLocalIndex>=0;
-         --nIndex,--nLocalIndex)
-    {
-        if (nIndex == 0 )
-            nLocalResult = 
maResourceURLs[nIndex].compareTo(rxId->getResourceURL());
-        else
-            nLocalResult = 
maResourceURLs[nIndex].compareTo(aAnchorURLs[nIndex-1]);
-        if (nLocalResult != 0)
-        {
-            if (nLocalResult < 0)
-                nResult = -1;
-            else
-                nResult = +1;
-            break;
-        }
-    }
-
-    if (nResult == 0)
-    {
-        // No difference found yet.  When the lengths are the same then the
-        // two resource ids are equivalent.  Otherwise the shorter comes
-        // first.
-        if (nLocalURLCount != nURLCount)
-        {
-            if (nLocalURLCount < nURLCount)
-                nResult = -1;
-            else
-                nResult = +1;
-        }
-    }
-
-    return nResult;
-}
-
 sal_Bool SAL_CALL
     ResourceId::isBoundTo (
         const Reference<XResourceId>& rxResourceId,
@@ -329,20 +264,8 @@ sal_Bool SAL_CALL
         return IsBoundToAnchor(nullptr, nullptr, eMode);
     }
 
-    ResourceId* pId = nullptr;
-#ifdef USE_OPTIMIZATIONS
-    pId = dynamic_cast<ResourceId*>(rxResourceId.get());
-#endif
-    if (pId != nullptr)
-    {
-        return IsBoundToAnchor(pId->maResourceURLs, eMode);
-    }
-    else
-    {
-        const OUString sResourceURL (rxResourceId->getResourceURL());
-        const Sequence<OUString> aAnchorURLs (rxResourceId->getAnchorURLs());
-        return IsBoundToAnchor(&sResourceURL, &aAnchorURLs, eMode);
-    }
+    ResourceId& rId = dynamic_cast<ResourceId&>(*rxResourceId);
+    return IsBoundToAnchor(rId.maResourceURLs, eMode);
 }
 
 sal_Bool SAL_CALL

Reply via email to