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-18 01:07:42 +0200 |
commit | c39e4f6b8a942680bc7250177c34fd034a0605e0 (patch) | |
tree | e7fb5be56a6f3a391ab420bede1d2ea714901777 /svl/source/items/poolitem.cxx | |
parent | 8ef9573f087b86f93860c8d07d04b60a40512836 (diff) |
Add SfxItemType to SfxPoolItem
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>
Diffstat (limited to 'svl/source/items/poolitem.cxx')
-rw-r--r-- | svl/source/items/poolitem.cxx | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx index bd4b62cb1419..491c30a7f50a 100644 --- a/svl/source/items/poolitem.cxx +++ b/svl/source/items/poolitem.cxx @@ -516,9 +516,10 @@ void DefaultItemInstanceManager::remove(const SfxPoolItem& rItem) { maRegistered ItemInstanceManager* SfxPoolItem::getItemInstanceManager() const { return nullptr; } -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 @@ -550,11 +551,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; } @@ -682,10 +682,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 @@ -704,10 +702,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 @@ -724,7 +720,11 @@ class InvalidOrDisabledItem final : public SfxPoolItem public: // make it StaticDefaultItem to process similar to these // which is plausible (never change and are not allowed to) - InvalidOrDisabledItem() { setStaticDefault(); } + InvalidOrDisabledItem() + : SfxPoolItem(0, SfxItemType::InvalidOrDisabledItemType) + { + setStaticDefault(); + } }; InvalidOrDisabledItem aInvalidItem; InvalidOrDisabledItem aDisabledItem; |