summaryrefslogtreecommitdiffstats
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-04-20 13:03:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-04-21 07:58:14 +0200
commitc757117afb398277a46e79ba22066c5bbf2c9f72 (patch)
tree0c27216e2364d8e8f0c27caf7accda36bfbc2ab2 /svl
parenttdf#101854 Move to CommonSalLayout removed faux bold in macos (diff)
downloadcore-c757117afb398277a46e79ba22066c5bbf2c9f72.tar.gz
core-c757117afb398277a46e79ba22066c5bbf2c9f72.zip
tdf#81765 slow loading of .ods with >1000 of conditional formats, part 2
This takes the loading time from 15s to 14s. Reduce unnecessary allocation/copying by passing down ownership of the newly created ScPatternAttr to the item pool Change-Id: Iec38bbff572d10ff8d86f5e65fbe9a96b6a5a706 Reviewed-on: https://gerrit.libreoffice.org/71010 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/itempool.cxx20
1 files changed, 17 insertions, 3 deletions
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 67f141dbd16b..bb3ac17f417b 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -27,6 +27,7 @@
#include <sal/log.hxx>
#include <svl/SfxBroadcaster.hxx>
#include <svl/hint.hxx>
+#include <svl/itemset.hxx>
#include <poolio.hxx>
#include <algorithm>
@@ -578,7 +579,7 @@ void SfxItemPool::ResetPoolDefaultItem( sal_uInt16 nWhichId )
}
-const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich )
+const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nWhich, bool bPassingOwnership )
{
if ( 0 == nWhich )
nWhich = rItem.Which();
@@ -588,7 +589,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
if ( !bSID && !IsInRange(nWhich) )
{
if ( pImpl->mpSecondary )
- return pImpl->mpSecondary->Put( rItem, nWhich );
+ return pImpl->mpSecondary->PutImpl( rItem, nWhich, bPassingOwnership );
OSL_FAIL( "unknown WhichId - cannot put item" );
}
@@ -601,6 +602,8 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
SfxPoolItem *pPoolItem = rItem.Clone(pImpl->mpMaster);
pPoolItem->SetWhich(nWhich);
AddRef( *pPoolItem );
+ if (bPassingOwnership)
+ delete &rItem;
return *pPoolItem;
}
@@ -623,6 +626,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
if (it != rItemArr.end())
{
AddRef(rItem);
+ assert(!bPassingOwnership && "cant be passing ownership and have the item already in the pool");
return rItem;
}
}
@@ -635,6 +639,8 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
{
assert(*pFoundItem == rItem);
AddRef(*pFoundItem);
+ if (bPassingOwnership)
+ delete &rItem;
return *pFoundItem;
}
}
@@ -645,6 +651,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
if (**itr == rItem)
{
AddRef(**itr);
+ assert(!bPassingOwnership && "cant be passing ownership and have the item already in the pool");
return **itr;
}
}
@@ -652,7 +659,14 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
}
// 3. not found, so clone to insert into the pointer array.
- SfxPoolItem* pNewItem = rItem.Clone(pImpl->mpMaster);
+ SfxPoolItem* pNewItem;
+ if (bPassingOwnership)
+ {
+ assert(!dynamic_cast<const SfxItemSet*>(&rItem) && "cant pass ownership of SfxItem, they need to be cloned to the master pool");
+ pNewItem = const_cast<SfxPoolItem*>(&rItem);
+ }
+ else
+ pNewItem = rItem.Clone(pImpl->mpMaster);
pNewItem->SetWhich(nWhich);
assert(typeid(rItem) == typeid(*pNewItem) && "SfxItemPool::Put(): unequal types, no Clone() override?");
if (dynamic_cast<const SfxSetItem*>(&rItem) == nullptr)