sw/source/core/unocore/unoobj2.cxx | 58 +++++++++++++++++-------------------- sw/source/core/unocore/unotext.cxx | 2 + 2 files changed, 30 insertions(+), 30 deletions(-)
New commits: commit 27e9fd67260b8ad321cf0f8722e2db8a08473927 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jun 13 09:01:50 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jun 13 10:30:01 2024 +0200 tdf#144208 speedup doc with lots of redline (7) reduce dynamic_cast cost Change-Id: I724fb5cfa7961d68c7011255d4ed5c2c89974566 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168764 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index b5a100b3f563..8867f49c22dd 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1122,6 +1122,16 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, const uno::Reference<text::XTextRange> & xTextRange, ::sw::TextRangeMode const eMode) { + SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get()); + if(pRange && &pRange->GetDoc() == &rToFill.GetDoc()) + { + return pRange->GetPositions(rToFill, eMode); + } + if (SwXParagraph* pPara = dynamic_cast<SwXParagraph*>(xTextRange.get())) + { + return pPara->SelectPaM(rToFill); + } + bool bRet = false; SwXHeadFootText* pHeadText @@ -1153,43 +1163,31 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); } - SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get()); - if(pRange && &pRange->GetDoc() == &rToFill.GetDoc()) + SwDoc* pDoc = nullptr; + const SwPaM* pUnoCursor = nullptr; + if (pCursor) { - bRet = pRange->GetPositions(rToFill, eMode); + pDoc = pCursor->GetDoc(); + pUnoCursor = pCursor->GetPaM(); } - else if (SwXParagraph* pPara = dynamic_cast<SwXParagraph*>(xTextRange.get())) + else if (SwXTextPortion* pPortion = dynamic_cast<SwXTextPortion*>(xTextRange.get())) { - bRet = pPara->SelectPaM(rToFill); + pDoc = &pPortion->GetCursor().GetDoc(); + pUnoCursor = &pPortion->GetCursor(); } - else + if (pUnoCursor && pDoc == &rToFill.GetDoc()) { - SwDoc* pDoc = nullptr; - const SwPaM* pUnoCursor = nullptr; - if (pCursor) + OSL_ENSURE(!pUnoCursor->IsMultiSelection(), + "what to do about rings?"); + bRet = true; + *rToFill.GetPoint() = *pUnoCursor->GetPoint(); + if (pUnoCursor->HasMark()) { - pDoc = pCursor->GetDoc(); - pUnoCursor = pCursor->GetPaM(); - } - else if (SwXTextPortion* pPortion = dynamic_cast<SwXTextPortion*>(xTextRange.get())) - { - pDoc = &pPortion->GetCursor().GetDoc(); - pUnoCursor = &pPortion->GetCursor(); - } - if (pUnoCursor && pDoc == &rToFill.GetDoc()) - { - OSL_ENSURE(!pUnoCursor->IsMultiSelection(), - "what to do about rings?"); - bRet = true; - *rToFill.GetPoint() = *pUnoCursor->GetPoint(); - if (pUnoCursor->HasMark()) - { - rToFill.SetMark(); - *rToFill.GetMark() = *pUnoCursor->GetMark(); - } - else - rToFill.DeleteMark(); + rToFill.SetMark(); + *rToFill.GetMark() = *pUnoCursor->GetMark(); } + else + rToFill.DeleteMark(); } return bRet; } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 7d0593221201..21088bc255df 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -970,10 +970,12 @@ SwXText::Impl::ComparePositions( { throw lang::IllegalArgumentException(); } +#ifdef DBG_UTIL if (!CheckForOwnMember(aPam1) || !CheckForOwnMember(aPam2)) { throw lang::IllegalArgumentException(); } +#endif sal_Int16 nCompare = 0; SwPosition const*const pStart1 = aPam1.Start();