diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-07-21 14:35:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-22 11:29:32 +0200 |
commit | c3e8dbc139c3b1644ea07101a8c1111572ffa017 (patch) | |
tree | 0c7bc8971c9093308c887c163a0bda4c4a19c92c /svl/source/items/globalpool.cxx | |
parent | 3133788fb5b8598ae275c566a9f55f88a668abf3 (diff) |
Improve the perf for pool item scanning..
for large complex documents with lots of shapes.
When that happens, we spend a lot of time scanning the std::unordered_set inside DefaultItemInstanceManager.
Since most of our items are already capable of being hashed, and thus avoiding the scanning cost, make it so we can use the HashableItemInstanceManager most of the time.
Change-Id: I43f4c04e956d316c976bea67d1941529d2d91182
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170813
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Tested-by: Armin Le Grand <Armin.Le.Grand@me.com>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl/source/items/globalpool.cxx')
-rw-r--r-- | svl/source/items/globalpool.cxx | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/svl/source/items/globalpool.cxx b/svl/source/items/globalpool.cxx index c5ecfba62c2a..9f0e26ef8547 100644 --- a/svl/source/items/globalpool.cxx +++ b/svl/source/items/globalpool.cxx @@ -125,7 +125,7 @@ void DefaultItemInstanceManager::remove(const SfxPoolItem& rItem) // ignored and start sharing ALL Item derivations instantly. class InstanceManagerHelper { - typedef std::unordered_map<SfxItemType, std::pair<sal_uInt16, DefaultItemInstanceManager*>> + typedef std::unordered_map<SfxItemType, std::pair<sal_uInt16, ItemInstanceManager*>> managerTypeMap; managerTypeMap maManagerPerType; @@ -169,7 +169,11 @@ public: if (g_bShareImmediately) { // create, insert locally and immediately start sharing - DefaultItemInstanceManager* pNew(new DefaultItemInstanceManager(rItem.ItemType())); + ItemInstanceManager* pNew; + if (rItem.supportsHashCode()) + pNew = new HashedItemInstanceManager(rItem.ItemType()); + else + pNew = new DefaultItemInstanceManager(rItem.ItemType()); maManagerPerType.insert({ rItem.ItemType(), std::make_pair(0, pNew) }); return pNew; } @@ -194,7 +198,11 @@ public: // here the countdown is zero and there is not yet a ItemInstanceManager // incarnated. Do so, register and return it assert(nullptr == aHit->second.second); - DefaultItemInstanceManager* pNew(new DefaultItemInstanceManager(rItem.ItemType())); + ItemInstanceManager* pNew; + if (rItem.supportsHashCode()) + pNew = new HashedItemInstanceManager(rItem.ItemType()); + else + pNew = new DefaultItemInstanceManager(rItem.ItemType()); aHit->second.second = pNew; return pNew; |