summaryrefslogtreecommitdiff
path: root/ucbhelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-07-19 12:26:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-20 13:00:45 +0200
commit1688af45e37144991eb09664a17b01d6be8f4792 (patch)
tree2e24bb62fef600f39712ea7eb618eb02be777a78 /ucbhelper
parent650818bf8387636afce9af3672abb84f29b99ee2 (diff)
no need to allocate Sequence separately in PropertySetInfo
Change-Id: If4843c3f419fac59ae8ce52b4004ce2dbb736f6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119215 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucbhelper')
-rw-r--r--ucbhelper/source/provider/contentinfo.cxx24
-rw-r--r--ucbhelper/source/provider/contentinfo.hxx5
2 files changed, 14 insertions, 15 deletions
diff --git a/ucbhelper/source/provider/contentinfo.cxx b/ucbhelper/source/provider/contentinfo.cxx
index 820fb021d9b2..394d8d01a8dd 100644
--- a/ucbhelper/source/provider/contentinfo.cxx
+++ b/ucbhelper/source/provider/contentinfo.cxx
@@ -62,10 +62,10 @@ PropertySetInfo::~PropertySetInfo()
// virtual
uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
{
- if ( !m_pProps )
+ if ( !m_xProps )
{
osl::MutexGuard aGuard( m_aMutex );
- if ( !m_pProps )
+ if ( !m_xProps )
{
// Get info for core ( native) properties.
@@ -73,9 +73,7 @@ uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
try
{
- uno::Sequence< beans::Property > aProps
- = m_pContent->getProperties( m_xEnv );
- m_pProps.reset(new uno::Sequence< beans::Property >( aProps ));
+ m_xProps = m_pContent->getProperties( m_xEnv );
}
catch ( uno::RuntimeException const & )
{
@@ -83,7 +81,7 @@ uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
}
catch ( uno::Exception const & )
{
- m_pProps.reset(new uno::Sequence< beans::Property >( 0 ));
+ m_xProps.emplace();
}
@@ -105,17 +103,17 @@ uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
sal_Int32 nAddProps = rAddProps.getLength();
if ( nAddProps > 0 )
{
- sal_Int32 nPos = m_pProps->getLength();
- m_pProps->realloc( nPos + nAddProps );
+ sal_Int32 nPos = m_xProps->getLength();
+ m_xProps->realloc( nPos + nAddProps );
std::copy(rAddProps.begin(), rAddProps.end(),
- std::next(m_pProps->begin(), nPos));
+ std::next(m_xProps->begin(), nPos));
}
}
}
}
}
- return *m_pProps;
+ return *m_xProps;
}
@@ -146,7 +144,7 @@ sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName(
void PropertySetInfo::reset()
{
osl::MutexGuard aGuard( m_aMutex );
- m_pProps.reset();
+ m_xProps.reset();
}
@@ -157,8 +155,8 @@ bool PropertySetInfo::queryProperty(
getProperties();
- const beans::Property* pProps = m_pProps->getConstArray();
- sal_Int32 nCount = m_pProps->getLength();
+ const beans::Property* pProps = m_xProps->getConstArray();
+ sal_Int32 nCount = m_xProps->getLength();
for ( sal_Int32 n = 0; n < nCount; ++n )
{
const beans::Property& rCurrProp = pProps[ n ];
diff --git a/ucbhelper/source/provider/contentinfo.hxx b/ucbhelper/source/provider/contentinfo.hxx
index 22591c8bc360..09e43c782453 100644
--- a/ucbhelper/source/provider/contentinfo.hxx
+++ b/ucbhelper/source/provider/contentinfo.hxx
@@ -21,6 +21,7 @@
#define UCBHELPER_SOURCE_PROVIDER_CONTENTINFO_HXX
#include <memory>
+#include <optional>
#include <com/sun/star/ucb/XCommandInfo.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
@@ -48,8 +49,8 @@ class PropertySetInfo :
{
css::uno::Reference< css::ucb::XCommandEnvironment >
m_xEnv;
- std::unique_ptr<css::uno::Sequence< css::beans::Property >>
- m_pProps;
+ std::optional<css::uno::Sequence< css::beans::Property >>
+ m_xProps;
osl::Mutex m_aMutex;
ContentImplHelper* m_pContent;