tdf#158556 avoid dynamic_cast

reduces load time by 2%

Change-Id: I8b31257baacd49657cccf7cc6bd04408581803c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172102
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2024-08-20 13:54:16 +02:00
parent 3e76f5e752
commit 17aae4ddab
3 changed files with 8 additions and 1 deletions
+2
View File
@@ -71,6 +71,8 @@ public:
/// Used to avoid cost of dynamic_cast in SdrViewIter::ImpFindView
virtual bool IsSdrView() const { return false; }
/// Used to avoid cost of dynamic_cast in SwXStyleFamily::FindStyle
virtual bool IsSwXStyle() const { return false; }
};
#endif
+3
View File
@@ -171,6 +171,9 @@ public:
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
//SvtListener
virtual void Notify(const SfxHint&) override;
//SfxListener
/// Used to avoid cost of dynamic_cast in SwXStyleFamily::FindStyle
virtual bool IsSwXStyle() const override final { return true; }
SW_DLLPUBLIC rtl::Reference<SwXNumberingRules> getNumberingRules();
+3 -1
View File
@@ -1190,7 +1190,9 @@ SwXStyle* SwXStyleFamily::FindStyle(std::u16string_view rStyleName) const
m_pBasePool->ForAllListeners(
[this, &pFoundStyle, &rStyleName] (SfxListener* pListener)
{
SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>(pListener);
if (!pListener->IsSwXStyle())
return false;
SwXStyle* pTempStyle = static_cast<SwXStyle*>(pListener);
if(pTempStyle && pTempStyle->GetFamily() == m_rEntry.family() && pTempStyle->GetStyleName() == rStyleName)
{
pFoundStyle = pTempStyle;