summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-06-01 11:14:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-06-01 18:11:49 +0200
commit49b9401465730b1151917bffcbc0ad1f0622fcee (patch)
treed8cfac0b39e42c741ceaefa70779ee1d88251362 /comphelper
parent754eb1541a6ca709f78afbc7fb2b75f626562dcc (diff)
no need to allocate guards on the heap
Change-Id: I66491a057f082a970158504474b678dbb4decf50 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135228 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/property/ChainablePropertySet.cxx16
-rw-r--r--comphelper/source/property/MasterPropertySet.cxx36
2 files changed, 26 insertions, 26 deletions
diff --git a/comphelper/source/property/ChainablePropertySet.cxx b/comphelper/source/property/ChainablePropertySet.cxx
index 65a53e62479f..7c9caa17582a 100644
--- a/comphelper/source/property/ChainablePropertySet.cxx
+++ b/comphelper/source/property/ChainablePropertySet.cxx
@@ -51,9 +51,9 @@ Reference< XPropertySetInfo > SAL_CALL ChainablePropertySet::getPropertySetInfo(
void SAL_CALL ChainablePropertySet::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
if (mpMutex)
- xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
+ xMutexGuard.emplace( mpMutex );
PropertyInfoHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
@@ -68,9 +68,9 @@ void SAL_CALL ChainablePropertySet::setPropertyValue( const OUString& rPropertyN
Any SAL_CALL ChainablePropertySet::getPropertyValue( const OUString& rPropertyName )
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
if (mpMutex)
- xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
+ xMutexGuard.emplace( mpMutex );
PropertyInfoHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
@@ -109,9 +109,9 @@ void SAL_CALL ChainablePropertySet::removeVetoableChangeListener( const OUString
void SAL_CALL ChainablePropertySet::setPropertyValues(const Sequence< OUString >& rPropertyNames, const Sequence< Any >& rValues)
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
if (mpMutex)
- xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
+ xMutexGuard.emplace( mpMutex );
const sal_Int32 nCount = rPropertyNames.getLength();
@@ -142,9 +142,9 @@ void SAL_CALL ChainablePropertySet::setPropertyValues(const Sequence< OUString >
Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues(const Sequence< OUString >& rPropertyNames)
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
if (mpMutex)
- xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
+ xMutexGuard.emplace( mpMutex );
const sal_Int32 nCount = rPropertyNames.getLength();
diff --git a/comphelper/source/property/MasterPropertySet.cxx b/comphelper/source/property/MasterPropertySet.cxx
index 3f6f0119dbb6..51fdd4deb620 100644
--- a/comphelper/source/property/MasterPropertySet.cxx
+++ b/comphelper/source/property/MasterPropertySet.cxx
@@ -32,12 +32,12 @@ namespace {
class AutoOGuardArray
{
- std::vector<std::unique_ptr< osl::Guard< comphelper::SolarMutex > >> maGuardArray;
+ std::vector<std::optional< osl::Guard< comphelper::SolarMutex > >> maGuardArray;
public:
explicit AutoOGuardArray( sal_Int32 nNumElements );
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > & operator[] ( sal_Int32 i ) { return maGuardArray[i]; }
+ std::optional< osl::Guard< comphelper::SolarMutex > > & operator[] ( sal_Int32 i ) { return maGuardArray[i]; }
};
}
@@ -91,9 +91,9 @@ void MasterPropertySet::registerSlave ( ChainablePropertySet *pNewSet )
void SAL_CALL MasterPropertySet::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
if (mpMutex)
- xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
+ xMutexGuard.emplace( mpMutex );
PropertyDataHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
@@ -111,9 +111,9 @@ void SAL_CALL MasterPropertySet::setPropertyValue( const OUString& rPropertyName
ChainablePropertySet * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]->mxSlave.get();
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard2;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard2;
if (pSlave->mpMutex)
- xMutexGuard2.reset( new osl::Guard< comphelper::SolarMutex >(pSlave->mpMutex) );
+ xMutexGuard2.emplace( pSlave->mpMutex );
pSlave->_preSetValues();
pSlave->_setSingleValue( *((*aIter).second->mpInfo), rValue );
@@ -124,9 +124,9 @@ void SAL_CALL MasterPropertySet::setPropertyValue( const OUString& rPropertyName
Any SAL_CALL MasterPropertySet::getPropertyValue( const OUString& rPropertyName )
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
if (mpMutex)
- xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
+ xMutexGuard.emplace( mpMutex );
PropertyDataHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
@@ -145,9 +145,9 @@ Any SAL_CALL MasterPropertySet::getPropertyValue( const OUString& rPropertyName
ChainablePropertySet * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]->mxSlave.get();
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard2;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard2;
if (pSlave->mpMutex)
- xMutexGuard2.reset( new osl::Guard< comphelper::SolarMutex >(pSlave->mpMutex) );
+ xMutexGuard2.emplace( pSlave->mpMutex );
pSlave->_preGetValues();
pSlave->_getSingleValue( *((*aIter).second->mpInfo), aAny );
@@ -180,9 +180,9 @@ void SAL_CALL MasterPropertySet::removeVetoableChangeListener( const OUString&,
void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues )
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
if (mpMutex)
- xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
+ xMutexGuard.emplace( mpMutex );
const sal_Int32 nCount = aPropertyNames.getLength();
@@ -220,7 +220,7 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >&
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
if (pSlave->mxSlave->mpMutex)
- aOGuardArray[i].reset( new osl::Guard< comphelper::SolarMutex >(pSlave->mxSlave->mpMutex) );
+ aOGuardArray[i].emplace( pSlave->mxSlave->mpMutex );
pSlave->mxSlave->_preSetValues();
pSlave->SetInit ( true );
@@ -243,9 +243,9 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >&
Sequence< Any > SAL_CALL MasterPropertySet::getPropertyValues( const Sequence< OUString >& aPropertyNames )
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
if (mpMutex)
- xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
+ xMutexGuard.emplace( mpMutex );
const sal_Int32 nCount = aPropertyNames.getLength();
@@ -281,7 +281,7 @@ Sequence< Any > SAL_CALL MasterPropertySet::getPropertyValues( const Sequence< O
{
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
if (pSlave->mxSlave->mpMutex)
- aOGuardArray[i].reset( new osl::Guard< comphelper::SolarMutex >(pSlave->mxSlave->mpMutex) );
+ aOGuardArray[i].emplace( pSlave->mxSlave->mpMutex );
pSlave->mxSlave->_preGetValues();
pSlave->SetInit ( true );
@@ -331,9 +331,9 @@ PropertyState SAL_CALL MasterPropertySet::getPropertyState( const OUString& Prop
ChainablePropertySet * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]->mxSlave.get();
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
- std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
+ std::optional< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
if (pSlave->mpMutex)
- xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(pSlave->mpMutex) );
+ xMutexGuard.emplace( pSlave->mpMutex );
}
return PropertyState_AMBIGUOUS_VALUE;