sw/source/core/doc/dbgoutsw.cxx        |    2 +-
 sw/source/core/doc/docedt.cxx          |    2 +-
 sw/source/core/doc/docfmt.cxx          |    2 +-
 sw/source/core/docnode/section.cxx     |    2 +-
 sw/source/core/fields/chpfld.cxx       |    2 +-
 sw/source/core/frmedt/fefly1.cxx       |    2 +-
 sw/source/core/layout/atrfrm.cxx       |    7 +++----
 sw/source/core/unocore/unoflatpara.cxx |    6 +++---
 sw/source/filter/ww8/ww8par.cxx        |    2 +-
 9 files changed, 13 insertions(+), 14 deletions(-)

New commits:
commit 61f660daef0e9c848087fbc7a8f95395c7093b8f
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Oct 17 10:38:38 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Oct 17 12:09:42 2022 +0200

    elide some dynamic_cast in writer
    
    we can use the virtual methods, which are faster
    
    Change-Id: I39215a7e5691cfd11623c0809799387344f14125
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141443
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx
index 5a3d7c86518b..9b7f37a219fc 100644
--- a/sw/source/core/doc/dbgoutsw.cxx
+++ b/sw/source/core/doc/dbgoutsw.cxx
@@ -593,7 +593,7 @@ static OUString lcl_dbg_out(const SwNode & rNode)
     {
         aTmpStr += "<start end=\"";
 
-        const SwStartNode * pStartNode = dynamic_cast<const SwStartNode *> 
(&rNode);
+        const SwStartNode * pStartNode = rNode.GetStartNode();
         if (pStartNode != nullptr)
             aTmpStr += 
OUString::number(sal_Int32(pStartNode->EndOfSectionNode()->GetIndex()));
 
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 55c43a041f93..3a085c1d060e 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -580,7 +580,7 @@ uno::Any SwDoc::Spell( SwPaM& rPaM,
                             // if grammar checking starts inside of a sentence 
the start position has to be adjusted
                             if( nBeginGrammarCheck )
                             {
-                                SwContentIndex aStartIndex( dynamic_cast< 
SwTextNode* >( pNd ), nBeginGrammarCheck );
+                                SwContentIndex aStartIndex( 
pNd->GetTextNode(), nBeginGrammarCheck );
                                 SwPosition aStart( *pNd, aStartIndex );
                                 SwCursor aCursor(aStart, nullptr);
                                 SwPosition aOrigPos = *aCursor.GetPoint();
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index d9eef9557cb4..2caaffe0efbb 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1032,7 +1032,7 @@ static bool lcl_SetTextFormatColl( SwNode* pNode, void* 
pArgs )
         {
             // Check, if the list style of the paragraph will change.
             bool bChangeOfListStyleAtParagraph( true );
-            SwTextNode& rTNd(dynamic_cast<SwTextNode&>(*pCNd));
+            SwTextNode& rTNd(*pCNd->GetTextNode());
             {
                 SwNumRule* pNumRuleAtParagraph(rTNd.GetNumRule());
                 if ( pNumRuleAtParagraph )
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index 975f72a9d607..a92694e5b58f 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -87,7 +87,7 @@ namespace {
         SwSectionNode* GetSectNode()
         {
             const SwNode* pSectNd( GetAnchor() );
-            return const_cast<SwSectionNode*>( dynamic_cast<const 
SwSectionNode*>( pSectNd ) );
+            return const_cast<SwSectionNode*>( pSectNd->GetSectionNode() );
         }
     };
 }
diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx
index fe591d11a6e8..a56a779e8928 100644
--- a/sw/source/core/fields/chpfld.cxx
+++ b/sw/source/core/fields/chpfld.cxx
@@ -136,7 +136,7 @@ void SwChapterField::ChangeExpansion(const SwFrame & rFrame,
 {
     SwDoc& rDoc = const_cast<SwDoc&>(pContentNode->GetDoc());
 
-    const SwTextNode* pTextNode = dynamic_cast<const 
SwTextNode*>(pContentNode);
+    const SwTextNode* pTextNode = pContentNode->GetTextNode();
     if (!pTextNode || !rFrame.IsInDocBody())
     {
         SwPosition aDummyPos( rDoc.GetNodes().GetEndOfContent() );
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index c5baab23358c..327601678e75 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -2113,7 +2113,7 @@ void SwFEShell::AlignAllFormulasToBaseline()
     while ( nullptr != (pStNd = aIdx.GetNode().GetStartNode()) )
     {
         ++aIdx;
-        SwOLENode *pOleNode = dynamic_cast< SwOLENode * >( &aIdx.GetNode() );
+        SwOLENode *pOleNode = aIdx.GetNode().GetOLENode();
         if ( pOleNode )
         {
             const uno::Reference < embed::XEmbeddedObject > & xObj( 
pOleNode->GetOLEObj().GetOleRef() );
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 96f3c751b325..bb4110ef46d8 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -1588,10 +1588,9 @@ void SwFormatAnchor::SetAnchor( const SwPosition *pPos )
     // anchor only to paragraphs, or start nodes in case of 
RndStdIds::FLY_AT_FLY
     // also allow table node, this is used when a table is selected and is 
converted to a frame by the UI
     assert(!pPos
-            || ((RndStdIds::FLY_AT_FLY == m_eAnchorId) &&
-                    dynamic_cast<SwStartNode*>(&pPos->GetNode()))
-            || (RndStdIds::FLY_AT_PARA == m_eAnchorId && 
dynamic_cast<SwTableNode*>(&pPos->GetNode()))
-            || dynamic_cast<SwTextNode*>(&pPos->GetNode()));
+            || (RndStdIds::FLY_AT_FLY == m_eAnchorId && 
pPos->GetNode().GetStartNode())
+            || (RndStdIds::FLY_AT_PARA == m_eAnchorId && 
pPos->GetNode().GetTableNode())
+            || pPos->GetNode().GetTextNode());
     if (pPos)
         m_oContentAnchor.emplace(*pPos);
     else
diff --git a/sw/source/core/unocore/unoflatpara.cxx 
b/sw/source/core/unocore/unoflatpara.cxx
index 553deb7560be..6fa124a824fd 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -464,7 +464,7 @@ uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getNextPara()
 
             ++mnCurrentNode;
 
-            pRet = dynamic_cast<SwTextNode*>(pNd);
+            pRet = pNd->GetTextNode();
             if ( pRet )
                 break;
 
@@ -521,7 +521,7 @@ uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getParaAfter(co
     for( SwNodeOffset nCurrentNode = pCurrentNode->GetIndex() + 1; 
nCurrentNode < rNodes.Count(); ++nCurrentNode )
     {
         SwNode* pNd = rNodes[ nCurrentNode ];
-        pNextTextNode = dynamic_cast<SwTextNode*>(pNd);
+        pNextTextNode = pNd->GetTextNode();
         if ( pNextTextNode )
             break;
     }
@@ -567,7 +567,7 @@ uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getParaBefore(c
     for( SwNodeOffset nCurrentNode = pCurrentNode->GetIndex() - 1; 
nCurrentNode > SwNodeOffset(0); --nCurrentNode )
     {
         SwNode* pNd = rNodes[ nCurrentNode ];
-        pPrevTextNode = dynamic_cast<SwTextNode*>(pNd);
+        pPrevTextNode = pNd->GetTextNode();
         if ( pPrevTextNode )
             break;
     }
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 8e6de1570e06..700b2765e247 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5454,7 +5454,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const 
*pGloss)
                                                          ? 
&(pNdIdx->GetNodes())
                                                          : nullptr;
                             const SwGrfNode *pGrf = (pNodesArray != nullptr)
-                                                    ? dynamic_cast<const 
SwGrfNode*>((*pNodesArray)[pNdIdx->GetIndex() + 1])
+                                                    ? 
(*pNodesArray)[pNdIdx->GetIndex() + 1]->GetGrfNode()
                                                     : nullptr;
                             vecBulletGrf.push_back(pGrf);
                         }

Reply via email to