diff options
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/invocation/invocation.cxx | 63 | ||||
-rw-r--r-- | stoc/source/proxy_factory/proxyfac.cxx | 33 | ||||
-rw-r--r-- | stoc/source/security/permissions.cxx | 18 | ||||
-rw-r--r-- | stoc/test/testsmgr_cpnt.cxx | 9 |
4 files changed, 43 insertions, 80 deletions
diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index 6cc658415bd6..271b90651400 100644 --- a/stoc/source/invocation/invocation.cxx +++ b/stoc/source/invocation/invocation.cxx @@ -970,76 +970,65 @@ void Invocation_Impl::fillInfoForMethod // XTypeProvider Sequence< Type > SAL_CALL Invocation_Impl::getTypes() { - static Sequence< Type > const * s_pTypes = nullptr; - if (! s_pTypes) - { - Sequence< Type > types( 4 + 10 ); - Type * pTypes = types.getArray(); + static Sequence<Type> s_types = [this]() { + Sequence<Type> types(4 + 10); + Type* pTypes = types.getArray(); sal_Int32 n = 0; - pTypes[ n++ ] = cppu::UnoType<XTypeProvider>::get(); - pTypes[ n++ ] = cppu::UnoType<XWeak>::get(); - pTypes[ n++ ] = cppu::UnoType<XInvocation>::get(); - pTypes[ n++ ] = cppu::UnoType<XMaterialHolder>::get(); + pTypes[n++] = cppu::UnoType<XTypeProvider>::get(); + pTypes[n++] = cppu::UnoType<XWeak>::get(); + pTypes[n++] = cppu::UnoType<XInvocation>::get(); + pTypes[n++] = cppu::UnoType<XMaterialHolder>::get(); // Invocation does not support XExactName if direct object supports // XInvocation, but not XExactName. - if ((_xDirect.is() && _xENDirect.is()) || - (!_xDirect.is() && _xENIntrospection.is())) + if ((_xDirect.is() && _xENDirect.is()) || (!_xDirect.is() && _xENIntrospection.is())) { - pTypes[ n++ ] = cppu::UnoType<XExactName>::get(); + pTypes[n++] = cppu::UnoType<XExactName>::get(); } - if( _xNameContainer.is() ) + if (_xNameContainer.is()) { - pTypes[ n++ ] = cppu::UnoType<XNameContainer>::get(); + pTypes[n++] = cppu::UnoType<XNameContainer>::get(); } - if( _xNameReplace.is() ) + if (_xNameReplace.is()) { - pTypes[ n++ ] = cppu::UnoType<XNameReplace>::get(); + pTypes[n++] = cppu::UnoType<XNameReplace>::get(); } - if( _xNameAccess.is() ) + if (_xNameAccess.is()) { - pTypes[ n++ ] = cppu::UnoType<XNameAccess>::get(); + pTypes[n++] = cppu::UnoType<XNameAccess>::get(); } if (_xIndexContainer.is()) { - pTypes[ n++ ] = cppu::UnoType<XIndexContainer>::get(); + pTypes[n++] = cppu::UnoType<XIndexContainer>::get(); } if (_xIndexReplace.is()) { - pTypes[ n++ ] = cppu::UnoType<XIndexReplace>::get(); + pTypes[n++] = cppu::UnoType<XIndexReplace>::get(); } if (_xIndexAccess.is()) { - pTypes[ n++ ] = cppu::UnoType<XIndexAccess>::get(); + pTypes[n++] = cppu::UnoType<XIndexAccess>::get(); } if (_xEnumerationAccess.is()) { - pTypes[ n++ ] = cppu::UnoType<XEnumerationAccess>::get(); + pTypes[n++] = cppu::UnoType<XEnumerationAccess>::get(); } if (_xElementAccess.is()) { - pTypes[ n++ ] = cppu::UnoType<XElementAccess>::get(); + pTypes[n++] = cppu::UnoType<XElementAccess>::get(); } // Invocation does not support XInvocation2, if direct object supports // XInvocation, but not XInvocation2. - if ( ( _xDirect.is() && _xDirect2.is()) || - (!_xDirect.is() && _xIntrospectionAccess.is() ) ) + if ((_xDirect.is() && _xDirect2.is()) || (!_xDirect.is() && _xIntrospectionAccess.is())) { - pTypes[ n++ ] = cppu::UnoType<XInvocation2>::get(); + pTypes[n++] = cppu::UnoType<XInvocation2>::get(); } - types.realloc( n ); - - // store types - MutexGuard guard( Mutex::getGlobalMutex() ); - if (! s_pTypes) - { - static Sequence< Type > s_types( types ); - s_pTypes = &s_types; - } - } - return *s_pTypes; + types.realloc(n); + return types; + }(); + return s_types; } Sequence< sal_Int8 > SAL_CALL Invocation_Impl::getImplementationId( ) diff --git a/stoc/source/proxy_factory/proxyfac.cxx b/stoc/source/proxy_factory/proxyfac.cxx index 57b0f2a05418..b85ed4907b9c 100644 --- a/stoc/source/proxy_factory/proxyfac.cxx +++ b/stoc/source/proxy_factory/proxyfac.cxx @@ -93,29 +93,16 @@ UnoInterfaceReference FactoryImpl::binuno_queryInterface( typelib_InterfaceTypeDescription * pTypeDescr ) { // init queryInterface() td - static typelib_TypeDescription * s_pQITD = nullptr; - if (s_pQITD == nullptr) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (s_pQITD == nullptr) - { - typelib_TypeDescription * pTXInterfaceDescr = nullptr; - TYPELIB_DANGER_GET( - &pTXInterfaceDescr, - cppu::UnoType<XInterface>::get().getTypeLibType() ); - typelib_TypeDescription * pQITD = nullptr; - typelib_typedescriptionreference_getDescription( - &pQITD, reinterpret_cast< typelib_InterfaceTypeDescription * >( - pTXInterfaceDescr )->ppAllMembers[ 0 ] ); - TYPELIB_DANGER_RELEASE( pTXInterfaceDescr ); - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - s_pQITD = pQITD; - } - } - else - { - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - } + static typelib_TypeDescription* s_pQITD = []() { + typelib_TypeDescription* pTXInterfaceDescr = nullptr; + TYPELIB_DANGER_GET(&pTXInterfaceDescr, cppu::UnoType<XInterface>::get().getTypeLibType()); + typelib_TypeDescription* pQITD = nullptr; + typelib_typedescriptionreference_getDescription( + &pQITD, reinterpret_cast<typelib_InterfaceTypeDescription*>(pTXInterfaceDescr) + ->ppAllMembers[0]); + TYPELIB_DANGER_RELEASE(pTXInterfaceDescr); + return pQITD; + }(); void * args[ 1 ]; args[ 0 ] = &reinterpret_cast< typelib_TypeDescription * >( diff --git a/stoc/source/security/permissions.cxx b/stoc/source/security/permissions.cxx index 1390275b3246..d8a4ac9b0c70 100644 --- a/stoc/source/security/permissions.cxx +++ b/stoc/source/security/permissions.cxx @@ -285,20 +285,12 @@ char const * FilePermission::s_actions [] = { "read", "write", "execute", "delet static OUString const & getWorkingDir() { - static OUString * s_workingDir = nullptr; - if (! s_workingDir) - { + static OUString s_workingDir = []() { OUString workingDir; - ::osl_getProcessWorkingDir( &workingDir.pData ); - - MutexGuard guard( Mutex::getGlobalMutex() ); - if (! s_workingDir) - { - static OUString s_dir( workingDir ); - s_workingDir = &s_dir; - } - } - return *s_workingDir; + ::osl_getProcessWorkingDir(&workingDir.pData); + return workingDir; + }(); + return s_workingDir; } FilePermission::FilePermission( diff --git a/stoc/test/testsmgr_cpnt.cxx b/stoc/test/testsmgr_cpnt.cxx index 638ad81c1cce..ddb6e4ca1b29 100644 --- a/stoc/test/testsmgr_cpnt.cxx +++ b/stoc/test/testsmgr_cpnt.cxx @@ -64,13 +64,8 @@ using namespace cppu; Reference<XMultiServiceFactory> getProcessServiceManager() { - Reference<XMultiServiceFactory > s_x; - if (! s_x.is()) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! s_x.is()) - s_x = createRegistryServiceFactory( OUString("stoctest.rdb"), sal_False ); - } + static Reference<XMultiServiceFactory> s_x( + createRegistryServiceFactory(OUString("stoctest.rdb"), sal_False)); return s_x; } |