summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-01-08 22:22:08 +0100
committerMichael Stahl <mst@openoffice.org>2010-01-08 22:22:08 +0100
commit5df534ab76ddcd831ea225d5154b75b4d9ff6cc8 (patch)
tree47d5a4ec62794420996ed88dbb3087938ce1d11a
parentb3910c8c1ac5ff22371440119341607b577304fc (diff)
swunolocking1: #i108161#: WeakReferenceHelper::operator=():
avoid creating a temporary WeakReferenceHelper for uno::Reference assignment. [according to callgrind this is 3 times faster]
-rw-r--r--cppuhelper/inc/cppuhelper/weakref.hxx29
-rwxr-xr-xcppuhelper/source/cc5_solaris_sparc.map1
-rw-r--r--cppuhelper/source/gcc3.map1
-rw-r--r--cppuhelper/source/weak.cxx18
4 files changed, 36 insertions, 13 deletions
diff --git a/cppuhelper/inc/cppuhelper/weakref.hxx b/cppuhelper/inc/cppuhelper/weakref.hxx
index ba4174db9..ab73e94a1 100644
--- a/cppuhelper/inc/cppuhelper/weakref.hxx
+++ b/cppuhelper/inc/cppuhelper/weakref.hxx
@@ -78,15 +78,17 @@ public:
@param rWeakRef another weak ref
*/
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.
@param rObj another weak ref
@@ -134,7 +136,18 @@ public:
inline WeakReference( const Reference< interface_type > & rRef ) SAL_THROW( () )
: 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 ff21cae7a..8614479ce 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 0cec45b6e..bbfbcbab2 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 2cd092cb8..bf0274c9a 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,9 +511,8 @@ WeakReferenceHelper& WeakReferenceHelper::operator=(const WeakReferenceHelper& r
m_pImpl->acquire();
}
}
- }
catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected()
- return *this;
+ return *this;
}
WeakReferenceHelper::~WeakReferenceHelper() SAL_THROW( () )