Kaydet (Commit) 73ed1178 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

add move assignment and constructor to uno::Reference

"perf stat" says:
Before  14,009,233,975,201      cycles
After   13,660,876,595,941      cycles
i.e. shaved roughly 2% of the cycles

Change-Id: If604a125a8a5040281abd699678d0c791d5bbb51
Reviewed-on: https://gerrit.libreoffice.org/20350Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst de9d0e79
...@@ -293,6 +293,14 @@ public: ...@@ -293,6 +293,14 @@ public:
*/ */
inline Reference( const Reference< interface_type > & rRef ); inline Reference( const Reference< interface_type > & rRef );
#if defined LIBO_INTERNAL_ONLY
/** Move constructor
@param rRef another reference
*/
inline Reference( Reference< interface_type > && rRef );
#endif
/** Up-casting conversion constructor: Copies interface reference. /** Up-casting conversion constructor: Copies interface reference.
Does not work for up-casts to ambiguous bases. For the special case of Does not work for up-casts to ambiguous bases. For the special case of
...@@ -540,7 +548,15 @@ public: ...@@ -540,7 +548,15 @@ public:
@return this reference @return this reference
*/ */
inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ); inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef );
#if defined LIBO_INTERNAL_ONLY
/** Assignment move operator: Acquires given interface reference and sets reference.
An interface already set will be released.
@param rRef an interface reference
@return this reference
*/
inline Reference< interface_type > & SAL_CALL operator = ( Reference< interface_type > && rRef );
#endif
/** Queries given interface reference for type interface_type. /** Queries given interface reference for type interface_type.
@param rRef interface reference @param rRef interface reference
......
...@@ -124,6 +124,15 @@ inline Reference< interface_type >::Reference( const Reference< interface_type > ...@@ -124,6 +124,15 @@ inline Reference< interface_type >::Reference( const Reference< interface_type >
_pInterface->acquire(); _pInterface->acquire();
} }
#if defined LIBO_INTERNAL_ONLY
template< class interface_type >
inline Reference< interface_type >::Reference( Reference< interface_type > && rRef )
{
_pInterface = rRef._pInterface;
rRef._pInterface = nullptr;
}
#endif
template< class interface_type > template< class derived_type > template< class interface_type > template< class derived_type >
inline Reference< interface_type >::Reference( inline Reference< interface_type >::Reference(
const Reference< derived_type > & rRef, const Reference< derived_type > & rRef,
...@@ -341,6 +350,18 @@ inline Reference< interface_type > & Reference< interface_type >::operator = ( ...@@ -341,6 +350,18 @@ inline Reference< interface_type > & Reference< interface_type >::operator = (
return *this; return *this;
} }
#if defined LIBO_INTERNAL_ONLY
template< class interface_type >
inline Reference< interface_type > & Reference< interface_type >::operator = (
Reference< interface_type > && rRef )
{
if (_pInterface)
_pInterface->release();
_pInterface = rRef._pInterface;
rRef._pInterface = nullptr;
return *this;
}
#endif
template< class interface_type > template< class interface_type >
inline Reference< interface_type > Reference< interface_type >::query( inline Reference< interface_type > Reference< interface_type >::query(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment