include/svl/lstner.hxx              |    2 ++
 sw/inc/unoxstyle.hxx                |    3 +++
 sw/source/core/unocore/unostyle.cxx |    4 +++-
 sw/source/core/unocore/unotext.cxx  |    3 +--
 4 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit ef8fd1a72a6b45bfb046efad47e61c11e8277e4a
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Aug 20 11:01:46 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Aug 20 13:54:24 2024 +0200

    tdf#158556 no need to create another cursor here
    
    we already have one for the insertion point
    
    Shaves 2% off load time
    
    Change-Id: I86d2d54c0eda3b74fde8929f075f744da4a083f0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172103
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/unocore/unotext.cxx 
b/sw/source/core/unocore/unotext.cxx
index b2f4b221e04e..7ed4b47a1004 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1338,8 +1338,7 @@ SwXText::appendTextPortion(
 {
     SolarMutexGuard aGuard;
     rtl::Reference< SwXTextCursor > xInsertPosition = getEndImpl(aGuard);
-    rtl::Reference<SwXTextCursor> xTextCursor = 
createXTextCursorByRange(xInsertPosition);
-    rtl::Reference< SwXTextRange > xRange = insertTextPortionImpl(aGuard, 
rText, rCharacterAndParagraphProperties, xTextCursor);
+    rtl::Reference< SwXTextRange > xRange = insertTextPortionImpl(aGuard, 
rText, rCharacterAndParagraphProperties, xInsertPosition);
     return xRange;
 }
 
commit 17aae4ddab1aad624779347d0fb914f635e7a4c7
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Aug 20 10:48:43 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Aug 20 13:54:16 2024 +0200

    tdf#158556 avoid dynamic_cast
    
    reduces load time by 2%
    
    Change-Id: I8b31257baacd49657cccf7cc6bd04408581803c7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172102
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/svl/lstner.hxx b/include/svl/lstner.hxx
index f9a35f10a84a..10c19b700db5 100644
--- a/include/svl/lstner.hxx
+++ b/include/svl/lstner.hxx
@@ -71,6 +71,8 @@ public:
 
     /// Used to avoid cost of dynamic_cast in SdrViewIter::ImpFindView
     virtual bool        IsSdrView() const { return false; }
+    /// Used to avoid cost of dynamic_cast in SwXStyleFamily::FindStyle
+    virtual bool        IsSwXStyle() const { return false; }
 };
 
 #endif
diff --git a/sw/inc/unoxstyle.hxx b/sw/inc/unoxstyle.hxx
index b33a8e4130b7..459dff27375e 100644
--- a/sw/inc/unoxstyle.hxx
+++ b/sw/inc/unoxstyle.hxx
@@ -171,6 +171,9 @@ public:
     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
     //SvtListener
     virtual void Notify(const SfxHint&) override;
+    //SfxListener
+    /// Used to avoid cost of dynamic_cast in SwXStyleFamily::FindStyle
+    virtual bool IsSwXStyle() const override final { return true; }
 
     SW_DLLPUBLIC rtl::Reference<SwXNumberingRules> getNumberingRules();
 
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 5c69f446d6ef..e1525ed25e1a 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1190,7 +1190,9 @@ SwXStyle* SwXStyleFamily::FindStyle(std::u16string_view 
rStyleName) const
     m_pBasePool->ForAllListeners(
         [this, &pFoundStyle, &rStyleName] (SfxListener* pListener)
         {
-            SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>(pListener);
+            if (!pListener->IsSwXStyle())
+                return false;
+            SwXStyle* pTempStyle = static_cast<SwXStyle*>(pListener);
             if(pTempStyle && pTempStyle->GetFamily() == m_rEntry.family() && 
pTempStyle->GetStyleName() == rStyleName)
             {
                 pFoundStyle = pTempStyle;

Reply via email to