diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-06-07 19:42:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-08 09:01:42 +0200 |
commit | e4f6840d0968ff9ea8976fdd735e1ecfe266cdde (patch) | |
tree | b6c45864f12504ef1da180a38ebb0872c52d268b /framework/source/services | |
parent | 93d6a7ca515909c657224cb2f8d5397c376b8017 (diff) |
framework: replace double checked locking patterns
with thread safe local statics.
Change-Id: I660f6a899d1821bab627ed4972c4fc0d40610de2
Reviewed-on: https://gerrit.libreoffice.org/38541
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework/source/services')
-rw-r--r-- | framework/source/services/autorecovery.cxx | 26 | ||||
-rw-r--r-- | framework/source/services/desktop.cxx | 23 |
2 files changed, 8 insertions, 41 deletions
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 48cb5bad7861..2a6ceb707af1 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -4024,35 +4024,17 @@ const css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescripto ::cppu::IPropertyArrayHelper& SAL_CALL AutoRecovery::getInfoHelper() { - static ::cppu::OPropertyArrayHelper* pInfoHelper = nullptr; - if(!pInfoHelper) - { - SolarMutexGuard g; - if(!pInfoHelper) - { - static ::cppu::OPropertyArrayHelper aInfoHelper(impl_getStaticPropertyDescriptor(), true); - pInfoHelper = &aInfoHelper; - } - } + static ::cppu::OPropertyArrayHelper ourInfoHelper(impl_getStaticPropertyDescriptor(), true); - return (*pInfoHelper); + return ourInfoHelper; } css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL AutoRecovery::getPropertySetInfo() { - static css::uno::Reference< css::beans::XPropertySetInfo >* pInfo = nullptr; - if(!pInfo) - { - SolarMutexGuard g; - if(!pInfo) - { - static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( + static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper())); - pInfo = &xInfo; - } - } - return (*pInfo); + return xInfo; } void AutoRecovery::implts_verifyCacheAgainstDesktopDocumentList() diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index 1791e857f4ec..be8b18f8a48b 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -1507,27 +1507,12 @@ css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropert // Register transaction and reject wrong calls. TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); - // Optimize this method ! - // We initialize a static variable only one time. And we don't must use a mutex at every call! - // For the first call; pInfo is NULL - for the second call pInfo is different from NULL! - static css::uno::Reference< css::beans::XPropertySetInfo >* pInfo = nullptr; - - if( pInfo == nullptr ) - { - SolarMutexGuard aGuard; - - // Control this pointer again, another instance can be faster then these! - if( pInfo == nullptr ) - { - // Create structure of propertysetinfo for baseclass "OPropertySetHelper". - // (Use method "getInfoHelper()".) - static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( + // Create structure of propertysetinfo for baseclass "OPropertySetHelper". + // (Use method "getInfoHelper()".) + static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ) ); - pInfo = &xInfo; - } - } - return (*pInfo); + return xInfo; } /*-************************************************************************************************************ |