editeng/source/editeng/impedit5.cxx | 41 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 23 deletions(-)
New commits: commit 1a4151dcdf45a0fa946b6ddf5e1b5cca37d24619 Author: Noel Grandin <noelgran...@collabora.co.uk> AuthorDate: Wed Nov 2 16:12:58 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Nov 2 19:47:02 2022 +0100 tdf#54857 elide more dynamic_cast re-arrange so we do the cheap checks before the expensive dynamic_cast Change-Id: Ief10b42894d15ab948e64c1189e0e7abf2c5a107 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142177 Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index 79825dc4d752..9a02ca4c4557 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -141,37 +141,32 @@ void ImpEditEngine::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) // So that not a lot of unnecessary formatting is done when destructing: if ( !bDowning ) { - - const SfxStyleSheetHint* pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint); - if ( pStyleSheetHint ) + SfxHintId nId = rHint.GetId(); + if ( ( nId == SfxHintId::StyleSheetInDestruction ) || + ( nId == SfxHintId::StyleSheetErased ) ) { - DBG_ASSERT( dynamic_cast< const SfxStyleSheet* >(pStyleSheetHint->GetStyleSheet()) != nullptr, "No SfxStyleSheet!" ); + const SfxStyleSheetHint* pStyleSheetHint = static_cast<const SfxStyleSheetHint*>(&rHint); SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStyleSheetHint->GetStyleSheet() ); - SfxHintId nId = pStyleSheetHint->GetId(); - if ( ( nId == SfxHintId::StyleSheetInDestruction ) || - ( nId == SfxHintId::StyleSheetErased ) ) - { - RemoveStyleFromParagraphs( pStyle ); - } - else if ( nId == SfxHintId::StyleSheetModified ) - { - UpdateParagraphsWithStyleSheet( pStyle ); - } + RemoveStyleFromParagraphs( pStyle ); } - else if ( auto pStyle = dynamic_cast< SfxStyleSheet* >(&rBC) ) + else if ( nId == SfxHintId::StyleSheetModified ) { - SfxHintId nId = rHint.GetId(); - if ( nId == SfxHintId::Dying ) - { + const SfxStyleSheetHint* pStyleSheetHint = static_cast<const SfxStyleSheetHint*>(&rHint); + SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStyleSheetHint->GetStyleSheet() ); + UpdateParagraphsWithStyleSheet( pStyle ); + } + else if ( nId == SfxHintId::Dying ) + { + if ( auto pStyle = dynamic_cast< SfxStyleSheet* >(&rBC) ) RemoveStyleFromParagraphs( pStyle ); - } - else if ( nId == SfxHintId::DataChanged ) - { + } + else if ( nId == SfxHintId::DataChanged ) + { + if ( auto pStyle = dynamic_cast< SfxStyleSheet* >(&rBC) ) UpdateParagraphsWithStyleSheet( pStyle ); - } } } - if(dynamic_cast<const SfxApplication*>(&rBC) != nullptr && rHint.GetId() == SfxHintId::Dying) + if (rHint.GetId() == SfxHintId::Dying && dynamic_cast<const SfxApplication*>(&rBC)) Dispose(); }