From 0aab9a48358f905de8d65568e5f32e8d36d6021c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 22:22:08 +0100 Subject: swunolocking1: #i108161#: WeakReferenceHelper::operator=(): avoid creating a temporary WeakReferenceHelper for uno::Reference assignment. [according to callgrind this is 3 times faster] --- cppuhelper/inc/cppuhelper/weakref.hxx | 21 +++++++++++++++++---- cppuhelper/source/cc5_solaris_sparc.map | 1 + cppuhelper/source/gcc3.map | 1 + cppuhelper/source/weak.cxx | 16 ++++++++++++---- 4 files changed, 31 insertions(+), 8 deletions(-) (limited to 'cppuhelper') diff --git a/cppuhelper/inc/cppuhelper/weakref.hxx b/cppuhelper/inc/cppuhelper/weakref.hxx index 01a4c7c6e0df..a8506f036f21 100644 --- a/cppuhelper/inc/cppuhelper/weakref.hxx +++ b/cppuhelper/inc/cppuhelper/weakref.hxx @@ -79,13 +79,15 @@ public: */ WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef ) SAL_THROW( () ); - /** Releases this reference and takes over hard reference xInt. If the implementation behind - xInt does not support XWeak or XInt is null, than this reference is null. + /** Releases this reference and takes over hard reference xInt. + If the implementation behind xInt does not support XWeak + or XInt is null, then this reference is null. @param xInt another hard reference */ - inline WeakReferenceHelper & SAL_CALL operator = ( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt ) SAL_THROW( () ) - { return operator = ( WeakReferenceHelper( xInt ) ); } + WeakReferenceHelper & SAL_CALL operator = ( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > & xInt ) SAL_THROW( () ); /** Returns true if both weak refs reference to the same object. @@ -135,6 +137,17 @@ public: : WeakReferenceHelper( rRef ) {} + /** Releases this reference and takes over hard reference xInt. + If the implementation behind xInt does not support XWeak + or XInt is null, then this reference is null. + + @param xInt another hard reference + */ + WeakReference & SAL_CALL operator = ( + const ::com::sun::star::uno::Reference< interface_type > & xInt ) + SAL_THROW( () ) + { WeakReferenceHelper::operator=(xInt); return *this; } + /** Gets a hard reference to the object. @return hard reference or null, if the weakly referenced interface has gone diff --git a/cppuhelper/source/cc5_solaris_sparc.map b/cppuhelper/source/cc5_solaris_sparc.map index 0961c6830d1f..0cda7be0bb7d 100755 --- a/cppuhelper/source/cc5_solaris_sparc.map +++ b/cppuhelper/source/cc5_solaris_sparc.map @@ -383,4 +383,5 @@ UDK_3.6 { # OOo 3.0 UDK_3.7 { # OOo 3.3 global: __1cEcppuLOWeakObjectbAdisposeWeakConnectionPoint6M_v_; + __1cDcomDsunEstarDunoTWeakReferenceHelper2G6Mrkn0DJReference4n0DKXInterface____r4_; } UDK_3.6; diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map index 9348e91525c0..6b6bac67d8f7 100644 --- a/cppuhelper/source/gcc3.map +++ b/cppuhelper/source/gcc3.map @@ -377,5 +377,6 @@ UDK_3.5 { # OOo 3.0 UDK_3.6 { # OOo 3.3 global: _ZN4cppu11OWeakObject26disposeWeakConnectionPointEv; + _ZN3com3sun4star3uno19WeakReferenceHelperaSERKNS2_9ReferenceINS2_10XInterfaceEEE; } UDK_3.5; diff --git a/cppuhelper/source/weak.cxx b/cppuhelper/source/weak.cxx index b518d2526e3b..1901610d40b7 100644 --- a/cppuhelper/source/weak.cxx +++ b/cppuhelper/source/weak.cxx @@ -481,11 +481,20 @@ WeakReferenceHelper::WeakReferenceHelper(const WeakReferenceHelper& rWeakRef) SA WeakReferenceHelper& WeakReferenceHelper::operator=(const WeakReferenceHelper& rWeakRef) SAL_THROW( () ) { - try + if (this == &rWeakRef) { - if (this != &rWeakRef) + return *this; + } + Reference< XInterface > xInt( rWeakRef.get() ); + return operator = ( xInt ); +} + +WeakReferenceHelper & SAL_CALL +WeakReferenceHelper::operator= (const Reference< XInterface > & xInt) +SAL_THROW( () ) +{ + try { - Reference< XInterface > xInt( rWeakRef.get() ); if (m_pImpl) { if (m_pImpl->m_XWeakConnectionPoint.is()) @@ -502,7 +511,6 @@ WeakReferenceHelper& WeakReferenceHelper::operator=(const WeakReferenceHelper& r m_pImpl->acquire(); } } - } catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected() return *this; } -- cgit v1.2.3 From bb94dd8918d401094768173d99ecf5a6efeb6739 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 11 Jan 2010 16:02:06 +0100 Subject: swunolocking1: #i108161#: add forgotten since tag --- cppuhelper/inc/cppuhelper/weakref.hxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cppuhelper') diff --git a/cppuhelper/inc/cppuhelper/weakref.hxx b/cppuhelper/inc/cppuhelper/weakref.hxx index a8506f036f21..a4f9f46eabd9 100644 --- a/cppuhelper/inc/cppuhelper/weakref.hxx +++ b/cppuhelper/inc/cppuhelper/weakref.hxx @@ -142,6 +142,8 @@ public: or XInt is null, then this reference is null. @param xInt another hard reference + + @since UDK 3.2.12 */ WeakReference & SAL_CALL operator = ( const ::com::sun::star::uno::Reference< interface_type > & xInt ) -- cgit v1.2.3 From bf46dbcd552d7538474af43b82eb16e17e02d0a4 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 13 Jan 2010 17:55:09 +0100 Subject: swunolocking1: #i108161#: WeakReferenceHelper: Apple g++ 4.0.1 erroneously believes that it is ambiguous to use WeakReference::operator=(Reference). as a workaround, introduce WeakReferenceHelper::clear(), and fix all users. --- cppuhelper/inc/cppuhelper/weakref.hxx | 6 +++++ cppuhelper/source/cc5_solaris_sparc.map | 1 + cppuhelper/source/gcc3.map | 1 + cppuhelper/source/msvc_win32_intel.map | 1 + cppuhelper/source/weak.cxx | 45 +++++++++++++++------------------ 5 files changed, 30 insertions(+), 24 deletions(-) (limited to 'cppuhelper') diff --git a/cppuhelper/inc/cppuhelper/weakref.hxx b/cppuhelper/inc/cppuhelper/weakref.hxx index a4f9f46eabd9..5ed14743a520 100644 --- a/cppuhelper/inc/cppuhelper/weakref.hxx +++ b/cppuhelper/inc/cppuhelper/weakref.hxx @@ -109,6 +109,12 @@ public: inline SAL_CALL operator Reference< XInterface > () const SAL_THROW( () ) { return get(); } + /** Releases this reference. + + @since UDK 3.2.12 + */ + void SAL_CALL clear() SAL_THROW( () ); + protected: /** @internal */ OWeakRefListener * m_pImpl; diff --git a/cppuhelper/source/cc5_solaris_sparc.map b/cppuhelper/source/cc5_solaris_sparc.map index 0cda7be0bb7d..941465519a08 100755 --- a/cppuhelper/source/cc5_solaris_sparc.map +++ b/cppuhelper/source/cc5_solaris_sparc.map @@ -384,4 +384,5 @@ UDK_3.7 { # OOo 3.3 global: __1cEcppuLOWeakObjectbAdisposeWeakConnectionPoint6M_v_; __1cDcomDsunEstarDunoTWeakReferenceHelper2G6Mrkn0DJReference4n0DKXInterface____r4_; + __1cDcomDsunEstarDunoTWeakReferenceHelperFclear6M_v_; } UDK_3.6; diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map index 6b6bac67d8f7..099373b2e220 100644 --- a/cppuhelper/source/gcc3.map +++ b/cppuhelper/source/gcc3.map @@ -378,5 +378,6 @@ UDK_3.6 { # OOo 3.3 global: _ZN4cppu11OWeakObject26disposeWeakConnectionPointEv; _ZN3com3sun4star3uno19WeakReferenceHelperaSERKNS2_9ReferenceINS2_10XInterfaceEEE; + _ZN3com3sun4star3uno19WeakReferenceHelper5clearEv; } UDK_3.5; diff --git a/cppuhelper/source/msvc_win32_intel.map b/cppuhelper/source/msvc_win32_intel.map index c999ae200ac2..6bc10cb175c2 100644 --- a/cppuhelper/source/msvc_win32_intel.map +++ b/cppuhelper/source/msvc_win32_intel.map @@ -275,4 +275,5 @@ UDK_3.5 { # OOo 3.0 UDK_3.6 { # OOo 3.3 global: ?disposeWeakConnectionPoint@OWeakObject@cppu@@IAEXXZ; + ?clear@WeakReferenceHelper@uno@star@sun@com@@QAAXXZ; } UDK_3.5; diff --git a/cppuhelper/source/weak.cxx b/cppuhelper/source/weak.cxx index 1901610d40b7..1fbfb3fa96ad 100644 --- a/cppuhelper/source/weak.cxx +++ b/cppuhelper/source/weak.cxx @@ -479,6 +479,25 @@ WeakReferenceHelper::WeakReferenceHelper(const WeakReferenceHelper& rWeakRef) SA } } +void WeakReferenceHelper::clear() SAL_THROW( () ) +{ + try + { + if (m_pImpl) + { + if (m_pImpl->m_XWeakConnectionPoint.is()) + { + m_pImpl->m_XWeakConnectionPoint->removeReference( + (XReference*)m_pImpl); + m_pImpl->m_XWeakConnectionPoint.clear(); + } + m_pImpl->release(); + m_pImpl = 0; + } + } + catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected() +} + WeakReferenceHelper& WeakReferenceHelper::operator=(const WeakReferenceHelper& rWeakRef) SAL_THROW( () ) { if (this == &rWeakRef) @@ -495,16 +514,7 @@ SAL_THROW( () ) { try { - if (m_pImpl) - { - if (m_pImpl->m_XWeakConnectionPoint.is()) - { - m_pImpl->m_XWeakConnectionPoint->removeReference((XReference*)m_pImpl); - m_pImpl->m_XWeakConnectionPoint.clear(); - } - m_pImpl->release(); - m_pImpl = 0; - } + clear(); if (xInt.is()) { m_pImpl = new OWeakRefListener(xInt); @@ -517,20 +527,7 @@ SAL_THROW( () ) WeakReferenceHelper::~WeakReferenceHelper() SAL_THROW( () ) { - try - { - if (m_pImpl) - { - if (m_pImpl->m_XWeakConnectionPoint.is()) - { - m_pImpl->m_XWeakConnectionPoint->removeReference((XReference*)m_pImpl); - m_pImpl->m_XWeakConnectionPoint.clear(); - } - m_pImpl->release(); - m_pImpl = 0; // for safety - } - } - catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected() + clear(); } Reference< XInterface > WeakReferenceHelper::get() const SAL_THROW( () ) -- cgit v1.2.3