Kaydet (Commit) 38a684f7 authored tarafından Noel Grandin's avatar Noel Grandin

move constructor for SfxItemSet

Change-Id: If7f51a657606da8aea4bcf01f13468c6ac2086a8
Reviewed-on: https://gerrit.libreoffice.org/71901
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d36331d6
...@@ -110,6 +110,7 @@ public: ...@@ -110,6 +110,7 @@ public:
struct Pair { sal_uInt16 wid1, wid2; }; struct Pair { sal_uInt16 wid1, wid2; };
SfxItemSet( const SfxItemSet& ); SfxItemSet( const SfxItemSet& );
SfxItemSet( SfxItemSet&& );
SfxItemSet( SfxItemPool&); SfxItemSet( SfxItemPool&);
template<sal_uInt16... WIDs> SfxItemSet( template<sal_uInt16... WIDs> SfxItemSet(
......
...@@ -222,31 +222,47 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ) ...@@ -222,31 +222,47 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet )
memcpy( m_pWhichRanges, rASet.m_pWhichRanges, sizeof( sal_uInt16 ) * cnt); memcpy( m_pWhichRanges, rASet.m_pWhichRanges, sizeof( sal_uInt16 ) * cnt);
} }
SfxItemSet::SfxItemSet( SfxItemSet&& rASet )
: m_pPool( rASet.m_pPool )
, m_pParent( rASet.m_pParent )
, m_pItems( std::move(rASet.m_pItems) )
, m_pWhichRanges( rASet.m_pWhichRanges )
, m_nCount( rASet.m_nCount )
{
rASet.m_pPool = nullptr;
rASet.m_pParent = nullptr;
rASet.m_pWhichRanges = nullptr;
rASet.m_nCount = 0;
}
SfxItemSet::~SfxItemSet() SfxItemSet::~SfxItemSet()
{ {
sal_uInt16 nCount = TotalCount(); if (m_pWhichRanges) // might be nullptr if we have been moved-from
if( Count() )
{ {
SfxPoolItem const** ppFnd = m_pItems.get(); sal_uInt16 nCount = TotalCount();
for( sal_uInt16 nCnt = nCount; nCnt; --nCnt, ++ppFnd ) if( Count() )
if( *ppFnd && !IsInvalidItem(*ppFnd) ) {
{ SfxPoolItem const** ppFnd = m_pItems.get();
if( !(*ppFnd)->Which() ) for( sal_uInt16 nCnt = nCount; nCnt; --nCnt, ++ppFnd )
delete *ppFnd; if( *ppFnd && !IsInvalidItem(*ppFnd) )
else { {
// Still multiple references present, so just alter the RefCount if( !(*ppFnd)->Which() )
if ( 1 < (*ppFnd)->GetRefCount() && !IsDefaultItem(*ppFnd) ) delete *ppFnd;
(*ppFnd)->ReleaseRef(); else {
else // Still multiple references present, so just alter the RefCount
if ( !IsDefaultItem(*ppFnd) ) if ( 1 < (*ppFnd)->GetRefCount() && !IsDefaultItem(*ppFnd) )
// Delete from Pool (*ppFnd)->ReleaseRef();
m_pPool->Remove( **ppFnd ); else
if ( !IsDefaultItem(*ppFnd) )
// Delete from Pool
m_pPool->Remove( **ppFnd );
}
} }
} }
} }
m_pItems.reset(); m_pItems.reset();
if (m_pWhichRanges != m_pPool->GetFrozenIdRanges()) if (m_pPool && m_pWhichRanges != m_pPool->GetFrozenIdRanges())
delete[] m_pWhichRanges; delete[] m_pWhichRanges;
m_pWhichRanges = nullptr; // for invariant-testing m_pWhichRanges = nullptr; // for invariant-testing
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment