summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-09-26 08:45:58 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-26 13:57:15 +0200
commit183729b7bdb98561dae2a3e8c9518fe4787ee6e3 (patch)
treedb682c1130bc4b8cd7f975dacc3eb440d611b2d7 /sw
parentaad712f6362378f19db2062f0499fd039c2f7114 (diff)
no need to allocate these SfxItemSet on the heap
Change-Id: Ic969f45ff35cdccf6603a5f9dcb94d1fdec9535c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122618 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/docsort.cxx14
-rw-r--r--sw/source/core/inc/docsort.hxx5
2 files changed, 10 insertions, 9 deletions
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index 1c927f6a30c1..24dcba033a30 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -881,18 +881,18 @@ void FlatFndBox::FillFlat(const FndBox_& rBox, bool bLastBox)
SfxItemState::SET == pFormat->GetItemState( RES_BOXATR_FORMULA ) ||
SfxItemState::SET == pFormat->GetItemState( RES_BOXATR_VALUE ) )
{
- auto pSet = std::make_unique<SfxItemSet>(
+ SfxItemSet aSet(
m_pDoc->GetAttrPool(),
svl::Items<
RES_VERT_ORIENT, RES_VERT_ORIENT,
RES_BOXATR_FORMAT, RES_BOXATR_VALUE>);
- pSet->Put( pFormat->GetAttrSet() );
- if( m_ppItemSets.empty() )
+ aSet.Put( pFormat->GetAttrSet() );
+ if( m_vItemSets.empty() )
{
size_t nCount = static_cast<size_t>(m_nRows) * m_nCols;
- m_ppItemSets.resize(nCount);
+ m_vItemSets.resize(nCount);
}
- m_ppItemSets[nOff] = std::move(pSet);
+ m_vItemSets[nOff].emplace(std::move(aSet));
}
bModRow = true;
@@ -924,9 +924,9 @@ const FndBox_* FlatFndBox::GetBox(sal_uInt16 n_Col, sal_uInt16 n_Row) const
const SfxItemSet* FlatFndBox::GetItemSet(sal_uInt16 n_Col, sal_uInt16 n_Row) const
{
- OSL_ENSURE( m_ppItemSets.empty() || ( n_Col < m_nCols && n_Row < m_nRows), "invalid array access");
+ OSL_ENSURE( m_vItemSets.empty() || ( n_Col < m_nCols && n_Row < m_nRows), "invalid array access");
- return !m_ppItemSets.empty() ? m_ppItemSets[unsigned(n_Row * m_nCols) + n_Col].get() : nullptr;
+ return !m_vItemSets.empty() ? &*m_vItemSets[unsigned(n_Row * m_nCols) + n_Col] : nullptr;
}
sal_uInt16 SwMovedBoxes::GetPos(const SwTableBox* pTableBox) const
diff --git a/sw/source/core/inc/docsort.hxx b/sw/source/core/inc/docsort.hxx
index a92754db521b..afe4fb1af530 100644
--- a/sw/source/core/inc/docsort.hxx
+++ b/sw/source/core/inc/docsort.hxx
@@ -134,7 +134,8 @@ private:
SwDoc* m_pDoc;
std::unique_ptr<FndBox_ const *[]> m_pArr;
- std::vector<std::unique_ptr<SfxItemSet>> m_ppItemSets;
+ /// using optional because SfxItemSet has no default constructor
+ std::vector<std::optional<SfxItemSet>> m_vItemSets;
sal_uInt16 m_nRows;
sal_uInt16 m_nCols;
@@ -144,7 +145,7 @@ private:
bool m_bSym;
};
-inline bool FlatFndBox::HasItemSets() const { return !m_ppItemSets.empty(); }
+inline bool FlatFndBox::HasItemSets() const { return !m_vItemSets.empty(); }
#endif