[Libreoffice-commits] core.git: include/com

Noel Grandin noel at peralex.com
Wed Dec 2 22:38:12 PST 2015


 include/com/sun/star/uno/Reference.h   |   16 ++++++++++++++++
 include/com/sun/star/uno/Reference.hxx |   21 +++++++++++++++++++++
 2 files changed, 37 insertions(+)

New commits:
commit 73ed1178034fb391882d348f99699579cdff643a
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Dec 2 12:58:50 2015 +0200

    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 <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/include/com/sun/star/uno/Reference.h b/include/com/sun/star/uno/Reference.h
index ba08688..8e266cd 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 498d5be..b25083d 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(


More information about the Libreoffice-commits mailing list