summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2017-06-17 12:00:17 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-17 13:28:18 +0200
commitd69795b9c9d2dac7b751c6fe8b4663c0c26a129b (patch)
treee900e25a1055aa46c3b54a63bb256a82cba370c6
parent76ed00f8db34490d5e21c72d142e11da510ac605 (diff)
use local statics in getTypes functions
... instead of double checked locking patterns. Change-Id: I1b86ce723ff22dd357b3ed69a52757b085472424 Reviewed-on: https://gerrit.libreoffice.org/38906 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basic/source/uno/namecont.cxx14
-rw-r--r--editeng/source/uno/unopracc.cxx21
-rw-r--r--ucb/source/cacher/cachedcontentresultsetstub.cxx39
-rw-r--r--unotools/source/ucbhelper/xtempfile.cxx15
-rw-r--r--xmlhelp/source/cxxhelp/provider/content.cxx16
-rw-r--r--xmlhelp/source/cxxhelp/provider/provider.cxx14
6 files changed, 30 insertions, 89 deletions
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 2e60ea4888b9..0d5a4c1b0e22 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -3130,21 +3130,13 @@ void SfxLibrary::removeByName( const OUString& Name )
// XTypeProvider
Sequence< Type > SfxLibrary::getTypes()
{
- static OTypeCollection * s_pTypes_NameContainer = nullptr;
- if( !s_pTypes_NameContainer )
- {
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if( !s_pTypes_NameContainer )
- {
- static OTypeCollection s_aTypes_NameContainer(
+ static OTypeCollection ourTypes_NameContainer(
cppu::UnoType<XNameContainer>::get(),
cppu::UnoType<XContainer>::get(),
cppu::UnoType<XChangesNotifier>::get(),
OComponentHelper::getTypes() );
- s_pTypes_NameContainer = &s_aTypes_NameContainer;
- }
- }
- return s_pTypes_NameContainer->getTypes();
+
+ return ourTypes_NameContainer.getTypes();
}
diff --git a/editeng/source/uno/unopracc.cxx b/editeng/source/uno/unopracc.cxx
index a26ddd2123a2..15ad7950bc90 100644
--- a/editeng/source/uno/unopracc.cxx
+++ b/editeng/source/uno/unopracc.cxx
@@ -27,7 +27,6 @@
#include <cppuhelper/weakref.hxx>
#include <editeng/unopracc.hxx>
#include <editeng/unoedsrc.hxx>
-#include <osl/mutex.hxx>
using namespace ::com::sun::star;
@@ -67,30 +66,14 @@ void SAL_CALL SvxAccessibleTextPropertySet::release()
// XTypeProvider
uno::Sequence< uno::Type > SAL_CALL SvxAccessibleTextPropertySet::getTypes()
{
- static ::cppu::OTypeCollection* pTypeCollection = nullptr ;
-
- // double-checked locking pattern.
- if ( pTypeCollection == nullptr )
- {
- osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
-
- // Control these pointer again ... it can be, that another instance will be faster then these!
- if ( pTypeCollection == nullptr )
- {
- // Create a static typecollection ...
- static ::cppu::OTypeCollection aTypeCollection(
+ static ::cppu::OTypeCollection ourTypeCollection(
::cppu::UnoType<beans::XPropertySet>::get(),
::cppu::UnoType<beans::XMultiPropertySet>::get(),
::cppu::UnoType<beans::XPropertyState>::get(),
::cppu::UnoType<lang::XServiceInfo>::get(),
::cppu::UnoType<lang::XTypeProvider>::get() );
- // ... and set his address to static pointer!
- pTypeCollection = &aTypeCollection ;
- }
- }
-
- return pTypeCollection->getTypes() ;
+ return ourTypeCollection.getTypes() ;
}
uno::Sequence< sal_Int8 > SAL_CALL SvxAccessibleTextPropertySet::getImplementationId()
diff --git a/ucb/source/cacher/cachedcontentresultsetstub.cxx b/ucb/source/cacher/cachedcontentresultsetstub.cxx
index 49d81c49bc37..c6ed4018072b 100644
--- a/ucb/source/cacher/cachedcontentresultsetstub.cxx
+++ b/ucb/source/cacher/cachedcontentresultsetstub.cxx
@@ -137,29 +137,22 @@ XTYPEPROVIDER_COMMON_IMPL( CachedContentResultSetStub )
Sequence< Type > SAL_CALL CachedContentResultSetStub
::getTypes()
{
- static Sequence< Type >* pTypes = nullptr;
- if( !pTypes )
- {
- osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
- if( !pTypes )
- {
- pTypes = new Sequence< Type >(13);
- (*pTypes)[0] = CPPU_TYPE_REF( XTypeProvider );
- (*pTypes)[1] = CPPU_TYPE_REF( XServiceInfo );
- (*pTypes)[2] = CPPU_TYPE_REF( XComponent );
- (*pTypes)[3] = CPPU_TYPE_REF( XCloseable );
- (*pTypes)[4] = CPPU_TYPE_REF( XResultSetMetaDataSupplier );
- (*pTypes)[5] = CPPU_TYPE_REF( XPropertySet );
- (*pTypes)[6] = CPPU_TYPE_REF( XPropertyChangeListener );
- (*pTypes)[7] = CPPU_TYPE_REF( XVetoableChangeListener );
- (*pTypes)[8] = CPPU_TYPE_REF( XResultSet );
- (*pTypes)[9] = CPPU_TYPE_REF( XContentAccess );
- (*pTypes)[10] = CPPU_TYPE_REF( XRow );
- (*pTypes)[11] = CPPU_TYPE_REF( XFetchProvider );
- (*pTypes)[12] = CPPU_TYPE_REF( XFetchProviderForContentAccess );
- }
- }
- return *pTypes;
+ static Sequence<Type> ourTypes(
+ { CPPU_TYPE_REF( XTypeProvider ),
+ CPPU_TYPE_REF( XServiceInfo ),
+ CPPU_TYPE_REF( XComponent ),
+ CPPU_TYPE_REF( XCloseable ),
+ CPPU_TYPE_REF( XResultSetMetaDataSupplier ),
+ CPPU_TYPE_REF( XPropertySet ),
+ CPPU_TYPE_REF( XPropertyChangeListener ),
+ CPPU_TYPE_REF( XVetoableChangeListener ),
+ CPPU_TYPE_REF( XResultSet ),
+ CPPU_TYPE_REF( XContentAccess ),
+ CPPU_TYPE_REF( XRow ),
+ CPPU_TYPE_REF( XFetchProvider ),
+ CPPU_TYPE_REF( XFetchProviderForContentAccess ) } );
+
+ return ourTypes;
}
diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx
index 9482a75598d6..eee00a7dde51 100644
--- a/unotools/source/ucbhelper/xtempfile.cxx
+++ b/unotools/source/ucbhelper/xtempfile.cxx
@@ -74,20 +74,11 @@ throw ()
css::uno::Sequence< css::uno::Type > SAL_CALL OTempFileService::getTypes( )
{
- static ::cppu::OTypeCollection* pTypeCollection = nullptr;
- if ( pTypeCollection == nullptr )
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-
- if ( pTypeCollection == nullptr )
- {
- static ::cppu::OTypeCollection aTypeCollection(
+ static ::cppu::OTypeCollection ourTypeCollection(
cppu::UnoType<css::beans::XPropertySet>::get()
,OTempFileBase::getTypes() );
- pTypeCollection = &aTypeCollection;
- }
- }
- return pTypeCollection->getTypes();
+
+ return ourTypeCollection.getTypes();
};
// XTempFile
diff --git a/xmlhelp/source/cxxhelp/provider/content.cxx b/xmlhelp/source/cxxhelp/provider/content.cxx
index beb3213eed41..1b7deb82f305 100644
--- a/xmlhelp/source/cxxhelp/provider/content.cxx
+++ b/xmlhelp/source/cxxhelp/provider/content.cxx
@@ -83,15 +83,8 @@ XTYPEPROVIDER_COMMON_IMPL( Content );
// virtual
uno::Sequence< uno::Type > SAL_CALL Content::getTypes()
{
- static cppu::OTypeCollection* pCollection = nullptr;
-
- if ( !pCollection )
- {
- osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() );
- if ( !pCollection )
- {
- static cppu::OTypeCollection aCollection(
- CPPU_TYPE_REF( lang::XTypeProvider ),
+ static cppu::OTypeCollection ourTypeCollection(
+ CPPU_TYPE_REF( lang::XTypeProvider ),
CPPU_TYPE_REF( lang::XServiceInfo ),
CPPU_TYPE_REF( lang::XComponent ),
CPPU_TYPE_REF( ucb::XContent ),
@@ -101,11 +94,8 @@ uno::Sequence< uno::Type > SAL_CALL Content::getTypes()
CPPU_TYPE_REF( beans::XPropertyContainer ),
CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ),
CPPU_TYPE_REF( container::XChild ) );
- pCollection = &aCollection;
- }
- }
- return (*pCollection).getTypes();
+ return ourTypeCollection.getTypes();
}
// XServiceInfo methods.
diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx
index b1bbf6ae467c..59c20e35ab74 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.cxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.cxx
@@ -90,23 +90,15 @@ css::uno::Sequence< sal_Int8 > SAL_CALL ContentProvider::getImplementationId()
css::uno::Sequence< css::uno::Type > SAL_CALL ContentProvider::getTypes()
{
- static cppu::OTypeCollection* pCollection = nullptr;
- if ( !pCollection )
- {
- osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
- if ( !pCollection )
- {
- static cppu::OTypeCollection collection(
+ static cppu::OTypeCollection ourTypeCollection(
cppu::UnoType<lang::XTypeProvider>::get(),
cppu::UnoType<lang::XServiceInfo>::get(),
cppu::UnoType<ucb::XContentProvider>::get(),
cppu::UnoType<lang::XComponent>::get(),
cppu::UnoType<container::XContainerListener>::get()
);
- pCollection = &collection;
- }
- }
- return (*pCollection).getTypes();
+
+ return ourTypeCollection.getTypes();
}