[Libreoffice-commits] core.git: sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sun Sep 26 11:57:48 UTC 2021
sw/source/core/doc/docsort.cxx | 14 +++++++-------
sw/source/core/inc/docsort.hxx | 5 +++--
2 files changed, 10 insertions(+), 9 deletions(-)
New commits:
commit 183729b7bdb98561dae2a3e8c9518fe4787ee6e3
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sun Sep 26 08:45:58 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Sep 26 13:57:15 2021 +0200
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 at collabora.co.uk>
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
More information about the Libreoffice-commits
mailing list