diff options
author | Eike Rathke <erack@redhat.com> | 2016-11-14 23:28:37 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-11-15 00:23:57 +0100 |
commit | bb50b1609abe83265311613db4a18e992dc666c8 (patch) | |
tree | 4be8864aca679d9140bd0031f67c323fdd0dbfaa /sc | |
parent | 3ab31ae5db001021069f25257454b7dee78e6dba (diff) |
sc-perf: HasAttrChanged: save unnecessary calls to SfxItemPool::Get()
SfxItemPool::GetItemState() can already return a pointer to a set item so that
doesn't need to be obtained again through SfxItemPool::Get()
tdf#103493 'LotroPlan 3.8.ods'
https://bugs.documentfoundation.org/attachment.cgi?id=128252
Incl. Self Called
Before:
10,210,820,257 1,162,295,513 34,670,201
After:
9,887,701,235 1,384,985,151 34,670,201
Only ~3% and 0.5% of the overall load time, but..
Change-Id: Icbed8a7982a27472fdfb1dbe4fd2061ab1e601bd
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/global.cxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 1436ecf2a587..50c5ba400652 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -141,29 +141,29 @@ bool ScGlobal::HasAttrChanged( const SfxItemSet& rNewAttrs, const sal_uInt16 nWhich ) { bool bInvalidate = false; - const SfxItemState eNewState = rNewAttrs.GetItemState( nWhich ); - const SfxItemState eOldState = rOldAttrs.GetItemState( nWhich ); + const SfxPoolItem* pNewItem = nullptr; + const SfxItemState eNewState = rNewAttrs.GetItemState( nWhich, true, &pNewItem ); + const SfxPoolItem* pOldItem = nullptr; + const SfxItemState eOldState = rOldAttrs.GetItemState( nWhich, true, &pOldItem ); if ( eNewState == eOldState ) { // Both Items set // PoolItems, meaning comparing pointers is valid if ( SfxItemState::SET == eOldState ) - bInvalidate = (&rNewAttrs.Get( nWhich ) != &rOldAttrs.Get( nWhich )); + bInvalidate = (pNewItem != pOldItem); } else { // Contains a Default Item // PoolItems, meaning Item comparison necessary - const SfxPoolItem& rOldItem = ( SfxItemState::SET == eOldState ) - ? rOldAttrs.Get( nWhich ) - : rOldAttrs.GetPool()->GetDefaultItem( nWhich ); + if (!pOldItem) + pOldItem = &rOldAttrs.GetPool()->GetDefaultItem( nWhich ); - const SfxPoolItem& rNewItem = ( SfxItemState::SET == eNewState ) - ? rNewAttrs.Get( nWhich ) - : rNewAttrs.GetPool()->GetDefaultItem( nWhich ); + if (!pNewItem) + pNewItem = &rNewAttrs.GetPool()->GetDefaultItem( nWhich ); - bInvalidate = rNewItem != rOldItem; + bInvalidate = (*pNewItem != *pOldItem); } return bInvalidate; |