summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-07-10 10:19:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-15 14:41:13 +0200
commit5d0a231b29dfd4d587c7a4d1bbda6a511f94ec77 (patch)
treeebc1d470fd891fe0f9e68a002055c4d3a8dd4884 /sd
parentdf9ca514d4e9ea87bbf0a96d99181ed8965cd45a (diff)
WhichRangesContainer, reduce malloc in SfxItemSet
SfxItemSet shows up in perf profiles frequently, and the hottest part is the malloc of the two arrays we need. But most of the time, one of those arrays is a compile-time constant. So this change introduces (*) WhichRangesContainer, which manages whether the SfxItemSet owns the array it points at or not. (*) a static const member in svl::Items (idea from mkaganski) to store the data. Change-Id: Icb8cdbc4d54fd76739565c575e16a744515e5355 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118703 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/dlg/paragr.cxx12
-rw-r--r--sd/source/ui/dlg/prltempl.cxx15
-rw-r--r--sd/source/ui/dlg/sddlgfact.cxx6
-rw-r--r--sd/source/ui/dlg/sddlgfact.hxx6
-rw-r--r--sd/source/ui/func/fupage.cxx28
-rw-r--r--sd/source/ui/func/futransf.cxx2
6 files changed, 31 insertions, 38 deletions
diff --git a/sd/source/ui/dlg/paragr.cxx b/sd/source/ui/dlg/paragr.cxx
index 1dd236a50e47..e7eec89fe998 100644
--- a/sd/source/ui/dlg/paragr.cxx
+++ b/sd/source/ui/dlg/paragr.cxx
@@ -36,7 +36,7 @@ public:
SdParagraphNumTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
- static const sal_uInt16* GetRanges();
+ static WhichRangesContainer GetRanges();
virtual bool FillItemSet( SfxItemSet* rSet ) override;
virtual void Reset( const SfxItemSet* rSet ) override;
@@ -68,15 +68,9 @@ std::unique_ptr<SfxTabPage> SdParagraphNumTabPage::Create(weld::Container* pPage
return std::make_unique<SdParagraphNumTabPage>(pPage, pController, *rAttrSet);
}
-const sal_uInt16* SdParagraphNumTabPage::GetRanges()
+WhichRangesContainer SdParagraphNumTabPage::GetRanges()
{
- static const sal_uInt16 aRange[] =
- {
- ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
- 0
- };
-
- return aRange;
+ return WhichRangesContainer(svl::Items<ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END>::value);
}
bool SdParagraphNumTabPage::FillItemSet( SfxItemSet* rSet )
diff --git a/sd/source/ui/dlg/prltempl.cxx b/sd/source/ui/dlg/prltempl.cxx
index a741d9ba39c4..a4ef27fed216 100644
--- a/sd/source/ui/dlg/prltempl.cxx
+++ b/sd/source/ui/dlg/prltempl.cxx
@@ -58,21 +58,20 @@ SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg(SfxObjectShell const * pDocSh,
if( IS_OUTLINE(ePO))
{
// Unfortunately, the Itemsets of our style sheets are not discrete...
- const sal_uInt16* pPtr = pOrgSet->GetRanges();
+ const WhichRangesContainer& pPtr = pOrgSet->GetRanges();
sal_uInt16 p1, p2;
- while( *pPtr )
+ for( sal_Int32 i = 0; i < pPtr.size(); ++i )
{
- p1 = pPtr[0];
- p2 = pPtr[1];
+ p1 = pPtr[i].first;
+ p2 = pPtr[i].second;
// first, we make it discrete
- while(pPtr[2] && (pPtr[2] - p2 == 1))
+ while(i < pPtr.size() - 1 && (pPtr[i+1].first - p2 == 1))
{
- p2 = pPtr[3];
- pPtr += 2;
+ p2 = pPtr[i+1].second;
+ ++i;
}
aInputSet.MergeRange( p1, p2 );
- pPtr += 2;
}
aInputSet.Put( rStyleBase.GetItemSet() );
diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx
index 0335c68fa8be..506b741e677d 100644
--- a/sd/source/ui/dlg/sddlgfact.cxx
+++ b/sd/source/ui/dlg/sddlgfact.cxx
@@ -271,7 +271,7 @@ const SfxItemSet* SdAbstractTabController_Impl::GetOutputItemSet() const
return m_xDlg->GetOutputItemSet();
}
-const sal_uInt16* SdAbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer SdAbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
{
return m_xDlg->GetInputRanges( pItem );
}
@@ -313,7 +313,7 @@ const SfxItemSet* AbstractBulletDialog_Impl::GetOutputItemSet() const
return static_cast< ::sd::OutlineBulletDlg*>(m_xDlg.get())->GetBulletOutputItemSet();
}
-const sal_uInt16* AbstractBulletDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer AbstractBulletDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
{
return m_xDlg->GetInputRanges(pItem);
}
@@ -349,7 +349,7 @@ const SfxItemSet* SdPresLayoutTemplateDlg_Impl::GetOutputItemSet() const
return m_xDlg->GetOutputItemSet();
}
-const sal_uInt16* SdPresLayoutTemplateDlg_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer SdPresLayoutTemplateDlg_Impl::GetInputRanges(const SfxItemPool& pItem )
{
return m_xDlg->GetInputRanges( pItem );
}
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index 6570c2b93b5d..5a8637586b8e 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -152,7 +152,7 @@ public:
virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
virtual void SetCurPageId( const OString &rName ) override;
virtual const SfxItemSet* GetOutputItemSet() const override;
- virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override;
+ virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
virtual void SetInputSet( const SfxItemSet* pInSet ) override;
virtual void SetText( const OUString& rStr ) override;
@@ -173,7 +173,7 @@ public:
virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
virtual void SetCurPageId( const OString& rName ) override;
virtual const SfxItemSet* GetOutputItemSet() const override;
- virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override;
+ virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
virtual void SetInputSet( const SfxItemSet* pInSet ) override;
virtual void SetText( const OUString& rStr ) override;
@@ -194,7 +194,7 @@ public:
virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
virtual void SetCurPageId( const OString& rName ) override;
virtual const SfxItemSet* GetOutputItemSet() const override;
- virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override;
+ virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
virtual void SetInputSet( const SfxItemSet* pInSet ) override;
virtual void SetText( const OUString& rStr ) override;
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 32b98a08bf58..982fab729734 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -77,21 +77,20 @@ namespace sd {
static void mergeItemSetsImpl( SfxItemSet& rTarget, const SfxItemSet& rSource )
{
- const sal_uInt16* pPtr = rSource.GetRanges();
+ const WhichRangesContainer& rRanges = rSource.GetRanges();
sal_uInt16 p1, p2;
- while( *pPtr )
+ for (sal_Int32 i = 0; i < rRanges.size(); ++i)
{
- p1 = pPtr[0];
- p2 = pPtr[1];
+ p1 = rRanges[i].first;
+ p2 = rRanges[i].second;
// make ranges discrete
- while(pPtr[2] && (pPtr[2] - p2 == 1))
+ while(i < rRanges.size()-1 && (rRanges[i+1].first - p2 == 1))
{
- p2 = pPtr[3];
- pPtr += 2;
+ p2 = rRanges[i+1].second;
+ ++i;
}
rTarget.MergeRange( p1, p2 );
- pPtr += 2;
}
rTarget.Put(rSource);
@@ -266,14 +265,15 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
// Merge ItemSet for dialog
- const sal_uInt16* pPtr = aNewAttr.GetRanges();
- sal_uInt16 p1 = pPtr[0], p2 = pPtr[1];
- while(pPtr[2] && (pPtr[2] - p2 == 1))
+ const WhichRangesContainer& rRanges = aNewAttr.GetRanges();
+ sal_uInt16 p1 = rRanges[0].first, p2 = rRanges[0].second;
+ sal_Int32 idx = 1;
+ while(idx < rRanges.size() && (rRanges[idx].first - p2 == 1))
{
- p2 = pPtr[3];
- pPtr += 2;
+ p2 = rRanges[idx].second;
+ ++idx;
}
- SfxItemSet aMergedAttr( *aNewAttr.GetPool(), {{p1, p2}} );
+ SfxItemSet aMergedAttr( *aNewAttr.GetPool(), p1, p2 );
mergeItemSetsImpl( aMergedAttr, aNewAttr );
diff --git a/sd/source/ui/func/futransf.cxx b/sd/source/ui/func/futransf.cxx
index 6c07e0e70be6..80441e57dea4 100644
--- a/sd/source/ui/func/futransf.cxx
+++ b/sd/source/ui/func/futransf.cxx
@@ -95,7 +95,7 @@ void FuTransform::DoExecute( SfxRequest& rReq )
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
pDlg.reset(pFact->CreateCaptionDialog(mpViewShell->GetFrameWeld(), mpView));
- const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
+ const WhichRangesContainer& pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange );
aCombSet.Put( aNewAttr );
aCombSet.Put( aSet );