diff options
author | Noel Grandin <noelgrandin@collabora.co.uk> | 2022-11-02 16:12:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-11-02 19:47:02 +0100 |
commit | 1a4151dcdf45a0fa946b6ddf5e1b5cca37d24619 (patch) | |
tree | 3bca834b1df34eb6aed7eba673af921a79c33138 | |
parent | 69910b540ae5140123fd2d4d67a9d338f980db53 (diff) |
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.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | editeng/source/editeng/impedit5.cxx | 41 |
1 files changed, 18 insertions, 23 deletions
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(); } |