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/source/weak.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'cppuhelper/source/weak.cxx') 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