diff options
author | Oliver Specht <oliver.specht@cib.de> | 2024-05-22 12:26:46 +0200 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2024-06-19 23:32:20 +0200 |
commit | 04a5157e9526c1570034fc88973a061138b133ea (patch) | |
tree | 8fa13473284d737147828fb0898c9abca7c9a86d /svl/source/items/poolitem.cxx | |
parent | 60c00a1d12fe531dbec8c285eaf8bfa02684be3c (diff) |
Add SfxItemType to SfxPoolItem
cib_contract49c-24.2.4.2.M1
The SfxPoolItem has a new member SfxItemType m_eItemType to
compare types based on enums instead of typeinfo() which
consumes a lot of time e.g. while AutoFormat is running
Change-Id: I033ce67bc9a28ee4790f162380314de85fb4154e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166452
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169185
Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'svl/source/items/poolitem.cxx')
-rw-r--r-- | svl/source/items/poolitem.cxx | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx index ae7c97136c48..d8395c836592 100644 --- a/svl/source/items/poolitem.cxx +++ b/svl/source/items/poolitem.cxx @@ -488,9 +488,10 @@ void listAllocatedSfxPoolItems() } #endif -SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich) +SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich, SfxItemType eType) : m_nRefCount(0) , m_nWhich(nWhich) + , m_eItemType(eType) #ifdef DBG_UTIL , m_nSerialNumber(nUsedSfxPoolItemCount) #endif @@ -524,11 +525,10 @@ SfxPoolItem::~SfxPoolItem() bool SfxPoolItem::operator==(const SfxPoolItem& rCmp) const { - SAL_WARN_IF(typeid(rCmp) != typeid(*this), "svl", + SAL_WARN_IF(rCmp.ItemType() != ItemType(), "svl", "comparing different pool item subclasses " << typeid(rCmp).name() << " && " << typeid(*this).name()); - assert(typeid(rCmp) == typeid(*this) && "comparing different pool item subclasses"); - (void)rCmp; + assert(rCmp.ItemType() == ItemType() && "comparing different pool item subclasses"); return true; } @@ -656,10 +656,8 @@ bool SfxPoolItem::areSame(const SfxPoolItem* pItem1, const SfxPoolItem* pItem2) // WhichIDs differ (fast) return false; - if (typeid(*pItem1) != typeid(*pItem2)) + if (pItem1->ItemType() != pItem2->ItemType()) // types differ (fast) - // NOTE: we can now use typeid since we do not have (-1) - // anymore for Invalid state -> safe return false; // return content compare using operator== at last @@ -678,10 +676,8 @@ bool SfxPoolItem::areSame(const SfxPoolItem& rItem1, const SfxPoolItem& rItem2) // WhichIDs differ (fast) return false; - if (typeid(rItem1) != typeid(rItem2)) + if (rItem1.ItemType() != rItem2.ItemType()) // types differ (fast) - // NOTE: we can now use typeid since we do not have (-1) - // anymore for Invalid state -> safe return false; // return content compare using operator== at last @@ -694,6 +690,15 @@ class InvalidItem final : public SfxPoolItem { virtual bool operator==(const SfxPoolItem&) const override { return true; } virtual SfxPoolItem* Clone(SfxItemPool*) const override { return nullptr; } + +public: + // make it StaticDefaultItem to process similar to these + // which is plausible (never change and are not allowed to) + InvalidItem() + : SfxPoolItem(0, SfxItemType::InvalidOrDisabledItemType) + { + setStaticDefault(); + } }; InvalidItem aInvalidItem; } |