summaryrefslogtreecommitdiff
path: root/sd/source/ui/func
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/source/ui/func
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/source/ui/func')
-rw-r--r--sd/source/ui/func/fupage.cxx28
-rw-r--r--sd/source/ui/func/futransf.cxx2
2 files changed, 15 insertions, 15 deletions
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 );