diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-19 11:40:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-19 18:41:01 +0200 |
commit | a7fa55386d0bcc7941b382658a7ace7017014e31 (patch) | |
tree | 54d786da0b3a74215ededceecc2af4a33c6214fb /ucb | |
parent | 87f6a73fd136ae3d342d09426a27fbde7dbe0fce (diff) |
no need to allocate separately in PropertySetInfo_Impl
Change-Id: Id5d4f360efd4e583557ba9d61544d34d895e0dcc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119208
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/core/ucbstore.cxx | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx index 91df7dc6a1cd..b7677e7cf707 100644 --- a/ucb/source/core/ucbstore.cxx +++ b/ucb/source/core/ucbstore.cxx @@ -24,7 +24,7 @@ *************************************************************************/ -#include <memory> +#include <optional> #include <unordered_map> #include <sal/log.hxx> #include <tools/diagnose_ex.h> @@ -112,8 +112,8 @@ namespace { class PropertySetInfo_Impl : public cppu::WeakImplHelper < XPropertySetInfo > { - std::unique_ptr<Sequence< Property >> - m_pProps; + std::optional<Sequence< Property >> + m_xProps; PersistentPropertySet* m_pOwner; public: @@ -125,7 +125,7 @@ public: virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override; // Non-interface methods. - void reset() { m_pProps.reset(); } + void reset() { m_xProps.reset(); } }; } @@ -2041,7 +2041,7 @@ PropertySetInfo_Impl::PropertySetInfo_Impl( // virtual Sequence< Property > SAL_CALL PropertySetInfo_Impl::getProperties() { - if ( !m_pProps ) + if ( !m_xProps ) { Reference< XHierarchicalNameAccess > xRootHierNameAccess( m_pOwner->getPropertySetRegistry().getRootConfigReadAccess(), @@ -2062,8 +2062,7 @@ Sequence< Property > SAL_CALL PropertySetInfo_Impl::getProperties() = xNameAccess->getElementNames(); sal_uInt32 nCount = aElems.getLength(); - Sequence< Property >* pPropSeq - = new Sequence< Property >( nCount ); + Sequence< Property > aPropSeq( nCount ); if ( nCount ) { @@ -2080,7 +2079,7 @@ Sequence< Property > SAL_CALL PropertySetInfo_Impl::getProperties() static const OUStringLiteral aValueName(u"/Value"); static const OUStringLiteral aAttrName(u"/Attributes"); - Property* pProps = pPropSeq->getArray(); + Property* pProps = aPropSeq.getArray(); for ( sal_uInt32 n = 0; n < nCount; ++n ) { @@ -2163,8 +2162,8 @@ Sequence< Property > SAL_CALL PropertySetInfo_Impl::getProperties() } // Success. - m_pProps.reset( pPropSeq ); - return *m_pProps; + m_xProps = std::move(aPropSeq); + return *m_xProps; } } catch (const NoSuchElementException&) @@ -2174,10 +2173,10 @@ Sequence< Property > SAL_CALL PropertySetInfo_Impl::getProperties() } OSL_FAIL( "PropertySetInfo_Impl::getProperties - Error!" ); - m_pProps.reset( new Sequence< Property >( 0 ) ); + m_xProps.emplace(); } - return *m_pProps; + return *m_xProps; } |