[Libreoffice-commits] core.git: include/svl svl/source
Eike Rathke
erack at redhat.com
Tue Jun 6 18:54:09 UTC 2017
include/svl/poolitem.hxx | 10 ++++++++++
svl/source/items/itemset.cxx | 2 +-
svl/source/items/poolitem.cxx | 9 +++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
New commits:
commit f300a627b9a88eb8814cc35844ed7c6aa7f19379
Author: Eike Rathke <erack at redhat.com>
Date: Tue Jun 6 20:53:00 2017 +0200
Perf-sc: tdf#100709 SfxPoolItem::IsVoidItem() instead of dynamic_cast
SfxItemSet::GetItemState()
before, Ir: 4 048 231 416
after, Ir: 2 577 117 709
Change-Id: I26d8b91ad5d851011a670b38b7b98e5582c319cf
diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index eae64a52388c..2eefbf1f66cf 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -177,6 +177,13 @@ public:
SfxItemKind GetKind() const { return m_nKind; }
virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
+ /** Only SfxVoidItem shall and must return true for this.
+
+ This avoids costly calls to dynamic_cast<const SfxVoidItem*>()
+ specifically in SfxItemSet::GetItemState()
+ */
+ virtual bool IsVoidItem() const;
+
private:
SfxPoolItem& operator=( const SfxPoolItem& ) = delete;
};
@@ -253,6 +260,9 @@ public:
// create a copy of itself
virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
+
+ /** Always returns true as this is an SfxVoidItem. */
+ virtual bool IsVoidItem() const override;
};
class SVL_DLLPUBLIC SfxSetItem: public SfxPoolItem
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index e69418456833..ddd821d85218 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -440,7 +440,7 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich,
// Different ones are present
return SfxItemState::DONTCARE;
- if ( dynamic_cast<const SfxVoidItem *>(*ppFnd) != nullptr )
+ if ( (*ppFnd)->IsVoidItem() )
return SfxItemState::DISABLED;
if (ppItem)
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index ba27df64fcf1..5c2c77cae919 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -136,6 +136,10 @@ SfxPoolItem* SfxPoolItem::CloneSetWhich( sal_uInt16 nNewWhich ) const
return pItem;
}
+bool SfxPoolItem::IsVoidItem() const
+{
+ return false;
+}
SfxPoolItem* SfxVoidItem::CreateDefault()
{
@@ -186,6 +190,11 @@ SfxPoolItem* SfxVoidItem::Clone(SfxItemPool *) const
return new SfxVoidItem(*this);
}
+bool SfxVoidItem::IsVoidItem() const
+{
+ return true;
+}
+
void SfxPoolItem::ScaleMetrics( long /*lMult*/, long /*lDiv*/ )
{
}
More information about the Libreoffice-commits
mailing list