svx/source/accessibility/AccessibleTextHelper.cxx | 61 ++++++++++------------ 1 file changed, 29 insertions(+), 32 deletions(-)
New commits: commit 5fb94180964c41980f14053056feb0ebfa38990d Author: Eike Rathke <er...@redhat.com> Date: Fri Nov 18 12:09:03 2016 +0100 perf: dynamic_cast only when necessary, arranged in likelihood of occurrence Ran into this during mass broadcasts happening when captions for note/ScPostIt objections are generated before saving a Calc document. Change-Id: I65940a8c8508649b041456ebaded9d672bb051f3 diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx index 7bfce1f..39ad4c8 100644 --- a/svx/source/accessibility/AccessibleTextHelper.cxx +++ b/svx/source/accessibility/AccessibleTextHelper.cxx @@ -1345,23 +1345,42 @@ namespace accessibility mbInNotify = true; - // determine hint type - const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>( &rHint ); - const TextHint* pTextHint = dynamic_cast<const TextHint*>( &rHint ); - const SvxViewChangedHint* pViewHint = dynamic_cast<const SvxViewChangedHint*>( &rHint ); - const SvxEditSourceHint* pEditSourceHint = dynamic_cast<const SvxEditSourceHint*>( &rHint ); - try { - // Process notification event - if( pEditSourceHint ) + // Process notification event, arranged in order of likelihood of + // occurrence to avoid unnecessary dynamic_cast. Note that + // SvxEditSourceHint is derived from TextHint, so has to be checked + // before that. + if( const SvxViewChangedHint* pViewHint = dynamic_cast<const SvxViewChangedHint*>( &rHint ) ) + { + maEventQueue.Append( *pViewHint ); + + // process visibility right away, if not within an + // open EE notification frame. Otherwise, event + // processing would be delayed until next EE + // notification sequence. + if( maEventOpenFrames == 0 ) + ProcessQueue(); + } + else if( const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>( &rHint ) ) + { + maEventQueue.Append( *pSdrHint ); + + // process drawing layer events right away, if not + // within an open EE notification frame. Otherwise, + // event processing would be delayed until next EE + // notification sequence. + if( maEventOpenFrames == 0 ) + ProcessQueue(); + } + else if( const SvxEditSourceHint* pEditSourceHint = dynamic_cast<const SvxEditSourceHint*>( &rHint ) ) { maEventQueue.Append( *pEditSourceHint ); // EditEngine should emit TEXT_SELECTION_CHANGED events (#i27299#) if( maEventOpenFrames == 0 ) ProcessQueue(); } - else if( pTextHint ) + else if( const TextHint* pTextHint = dynamic_cast<const TextHint*>( &rHint ) ) { switch( pTextHint->GetId() ) { @@ -1406,29 +1425,7 @@ namespace accessibility break; } } - else if( pViewHint ) - { - maEventQueue.Append( *pViewHint ); - - // process visibility right away, if not within an - // open EE notification frame. Otherwise, event - // processing would be delayed until next EE - // notification sequence. - if( maEventOpenFrames == 0 ) - ProcessQueue(); - } - else if( pSdrHint ) - { - maEventQueue.Append( *pSdrHint ); - - // process drawing layer events right away, if not - // within an open EE notification frame. Otherwise, - // event processing would be delayed until next EE - // notification sequence. - if( maEventOpenFrames == 0 ) - ProcessQueue(); - } - // it's VITAL to keep the SfxSimpleHint last! It's the base of some classes above! + // it's VITAL to keep the SfxHint last! It's the base of the classes above! else if( rHint.GetId() ) { // handle this event _at once_, because after that, objects are invalid _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits