summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-11-18 12:09:03 +0100
committerEike Rathke <erack@redhat.com>2016-11-18 12:09:35 +0100
commit5fb94180964c41980f14053056feb0ebfa38990d (patch)
treebe53dad86bd23e94b1e14a62b8990ed5135d8a56 /svx
parentfde0892f2d77c19b2c281aece7d20244640aa147 (diff)
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
Diffstat (limited to 'svx')
-rw-r--r--svx/source/accessibility/AccessibleTextHelper.cxx61
1 files changed, 29 insertions, 32 deletions
diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx
index 7bfce1f59169..39ad4c88b44e 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