diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2024-07-26 20:15:56 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-29 08:01:06 +0200 |
commit | be5fad6d0755e3d1e7ab5c9d4bfda8248b4e51d2 (patch) | |
tree | cee960173af9fc359792482397a8c67597328fc3 /svl/source/items/poolitem.cxx | |
parent | 46f7dcc5f499892ef093147b3f739c258bbf6b81 (diff) |
tdf#161875 buffer NameOrIndex Items for fast Surrogates
Problem is that collecting the Items using the ItemSets and
PoolItemHolders is too expensive when used too often. For
read-only access it is okay to have the Items directly
registerd (for write access we *need* the ItemSets and
PoolItemHolders, see iterateItemSurrogates).
This is limited to Items which need to support surrogates,
but can further be limited to the here critical ones - the
ones derived from NameOrIndex.
This is done here by checking if the Item is a NameOrIndex
based one by adding a bool to the item that gets set in the
NameOrIndex constructor. If needed this can be changed,
e.g. by using besides the SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
another flag signaling this.
Since only Items that are currently held by an ItemSet or a
PoolItemHolder get registered it is not necessary to change
the Item's RefCount in any way, doing that may lead (again,
we had that with directly set Items at the Pool in the past)
to long-living Items that only get cleaned-up when the pool/
document gets destructed.
This buffering is now SfxItemType-based, no longer using the
WhichID, so the result needs to be checked for WhichID
additionally - if needed (?).
All in all it's anyways a compromize, every usage of the
surrogate mechanism is a 'hack' in the sense that for lazy
reasons not the model data is traversed directly, but assumed
that all Items set at a pool/model *are* model/document data
(what is not always true).
CheckNamedItem does not need to be static, changed that.
Also all accesses to maRegisteredNameOrIndex *have* to
work on the MasterPool instance, same as buffered ItemSets
or PoolItemHolders, corrected that, too.
Number of instances in the buffer need to be counted, else
an instance will be removed too early: The same instance
of an Item can be referenced by multiple sets/holders,
so the first remove from the buffer would already remove
even when the Item is referenced multiple times. Added
that.
Added more asserts & made sure that all constructors/
destructors of SfxItemSet do take care of registering
Items for the surrogate mechanism as needed.
Change-Id: Ib33e7f0bd4abd32a3bb68278f33b0abb9a4754c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171084
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'svl/source/items/poolitem.cxx')
-rw-r--r-- | svl/source/items/poolitem.cxx | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx index 85aa8b998878..dd628225a7d8 100644 --- a/svl/source/items/poolitem.cxx +++ b/svl/source/items/poolitem.cxx @@ -526,6 +526,7 @@ SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich, SfxItemType eType) , m_bDynamicDefault(false) , m_bIsSetItem(false) , m_bShareable(true) + , m_bNameOrIndex(false) #ifdef DBG_UTIL , m_bDeleted(false) #endif |