From 73ed1178034fb391882d348f99699579cdff643a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 2 Dec 2015 12:58:50 +0200 Subject: 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/20350 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- include/com/sun/star/uno/Reference.h | 16 ++++++++++++++++ include/com/sun/star/uno/Reference.hxx | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'include/com/sun/star/uno') diff --git a/include/com/sun/star/uno/Reference.h b/include/com/sun/star/uno/Reference.h index ba0868846702..8e266cd72f43 100644 --- a/include/com/sun/star/uno/Reference.h +++ b/include/com/sun/star/uno/Reference.h @@ -293,6 +293,14 @@ public: */ 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. Does not work for up-casts to ambiguous bases. For the special case of @@ -540,7 +548,15 @@ public: @return this reference */ 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. @param rRef interface reference diff --git a/include/com/sun/star/uno/Reference.hxx b/include/com/sun/star/uno/Reference.hxx index 498d5be4b46d..b25083d8e030 100644 --- a/include/com/sun/star/uno/Reference.hxx +++ b/include/com/sun/star/uno/Reference.hxx @@ -124,6 +124,15 @@ inline Reference< interface_type >::Reference( const Reference< interface_type > _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 > inline Reference< interface_type >::Reference( const Reference< derived_type > & rRef, @@ -341,6 +350,18 @@ inline Reference< interface_type > & Reference< interface_type >::operator = ( 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 > inline Reference< interface_type > Reference< interface_type >::query( -- cgit