summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-05-08 08:29:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-05-09 08:47:50 +0200
commite0382c3ad7786910bc9aa81cf581798df0f2508c (patch)
tree6acb0196add99896ced2aa1a76ff5b432bc45401 /include
parent38a684f72988f29e1c07bf9fa5a83e275e80e24c (diff)
avoid copying when placing items into SfxItemSet
Change-Id: I05c627f590e7794c1ba11b66021dc30aa3285eb0 Reviewed-on: https://gerrit.libreoffice.org/71941 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r--include/svl/itempool.hxx2
-rw-r--r--include/svl/itemset.hxx13
2 files changed, 12 insertions, 3 deletions
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index 3a2ff084d723..4c9052df0a13 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -57,6 +57,8 @@ protected:
class SVL_DLLPUBLIC SfxItemPool
{
friend struct SfxItemPool_Impl;
+ friend class SfxItemSet;
+ friend class SfxAllItemSet;
const SfxItemInfo* pItemInfos;
std::unique_ptr<SfxItemPool_Impl> pImpl;
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 88aecf5b6e06..9892855657d1 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -106,6 +106,8 @@ protected:
void PutDirect(const SfxPoolItem &rItem);
+ virtual const SfxPoolItem* PutImpl( const SfxPoolItem&, sal_uInt16 nWhich, bool bPassingOwnership );
+
public:
struct Pair { sal_uInt16 wid1, wid2; };
@@ -191,9 +193,14 @@ public:
// add, delete items, work on items
public:
- virtual const SfxPoolItem* Put( const SfxPoolItem&, sal_uInt16 nWhich );
+ const SfxPoolItem* Put( const SfxPoolItem& rItem, sal_uInt16 nWhich )
+ { return PutImpl(rItem, nWhich, /*bPassingOwnership*/false); }
+ const SfxPoolItem* Put( std::unique_ptr<SfxPoolItem> xItem, sal_uInt16 nWhich )
+ { return PutImpl(*xItem.release(), nWhich, /*bPassingOwnership*/true); }
const SfxPoolItem* Put( const SfxPoolItem& rItem )
{ return Put(rItem, rItem.Which()); }
+ const SfxPoolItem* Put( std::unique_ptr<SfxPoolItem> xItem )
+ { auto nWhich = xItem->Which(); return Put(std::move(xItem), nWhich); }
bool Put( const SfxItemSet&,
bool bInvalidAsDefault = true );
void PutExtended( const SfxItemSet&,
@@ -249,8 +256,8 @@ public:
SfxAllItemSet( const SfxAllItemSet & );
virtual std::unique_ptr<SfxItemSet> Clone( bool bItems = true, SfxItemPool *pToPool = nullptr ) const override;
- virtual const SfxPoolItem* Put( const SfxPoolItem&, sal_uInt16 nWhich ) override;
- using SfxItemSet::Put;
+protected:
+ virtual const SfxPoolItem* PutImpl( const SfxPoolItem&, sal_uInt16 nWhich, bool bPassingOwnership ) override;
};
#endif // INCLUDED_SVL_ITEMSET_HXX