summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-11 17:13:03 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-12 09:08:13 +0200
commit7281f4a73ec3679798a6271ab5a0ad839f278e37 (patch)
tree3cca53740da25547641c8c8d31dd673aee9d7b35 /svl
parent8ff99af537b2daff07717990be10780ad6824f25 (diff)
use std::unique_ptr in TItemInfo
and inline the TItems typedef Change-Id: I0c50d12d53ce4b52c330cad8790a65065ebdd82e Reviewed-on: https://gerrit.libreoffice.org/42182 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/config/itemholder2.cxx22
-rw-r--r--svl/source/config/itemholder2.hxx2
2 files changed, 7 insertions, 17 deletions
diff --git a/svl/source/config/itemholder2.cxx b/svl/source/config/itemholder2.cxx
index 1511b47082a3..b809eba57b1d 100644
--- a/svl/source/config/itemholder2.cxx
+++ b/svl/source/config/itemholder2.cxx
@@ -79,12 +79,8 @@ void ItemHolder2::impl_addItem(EItem eItem)
{
::osl::ResettableMutexGuard aLock(m_aLock);
- TItems::const_iterator pIt;
- for ( pIt = m_lItems.begin();
- pIt != m_lItems.end() ;
- ++pIt )
+ for ( auto const & rInfo : m_lItems )
{
- const TItemInfo& rInfo = *pIt;
if (rInfo.eItem == eItem)
return;
}
@@ -93,24 +89,18 @@ void ItemHolder2::impl_addItem(EItem eItem)
aNewItem.eItem = eItem;
impl_newItem(aNewItem);
if (aNewItem.pItem)
- m_lItems.push_back(aNewItem);
+ m_lItems.emplace_back(std::move(aNewItem));
}
void ItemHolder2::impl_releaseAllItems()
{
- TItems items;
+ std::vector< TItemInfo > items;
{
::osl::MutexGuard aLock(m_aLock);
items.swap(m_lItems);
}
- TItems::iterator pIt;
- for ( pIt = items.begin();
- pIt != items.end() ;
- ++pIt )
- {
- delete pIt->pItem;
- }
+ // items will be freed when the block exits
}
void ItemHolder2::impl_newItem(TItemInfo& rItem)
@@ -118,11 +108,11 @@ void ItemHolder2::impl_newItem(TItemInfo& rItem)
switch(rItem.eItem)
{
case EItem::CJKOptions :
- rItem.pItem = new SvtCJKOptions();
+ rItem.pItem.reset( new SvtCJKOptions() );
break;
case EItem::CTLOptions :
- rItem.pItem = new SvtCTLOptions();
+ rItem.pItem.reset( new SvtCTLOptions() );
break;
default:
diff --git a/svl/source/config/itemholder2.hxx b/svl/source/config/itemholder2.hxx
index 3246cc37b4dd..27d9f182ff03 100644
--- a/svl/source/config/itemholder2.hxx
+++ b/svl/source/config/itemholder2.hxx
@@ -30,7 +30,7 @@ class ItemHolder2 : private ItemHolderMutexBase
// member
private:
- TItems m_lItems;
+ std::vector<TItemInfo> m_lItems;
// c++ interface
public: