include/com/sun/star/uno/Any.hxx |   35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

New commits:
commit 084b2b068ad6729775f7fa5965429fc5cc3c2ae3
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed May 18 20:57:45 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri May 20 09:40:38 2022 +0200

    optimise Any::operator=(&&) a little
    
    uno_any_destruct will get called by the other Any anyway, so no need to
    do it ourselves.
    And inline the helper now, since it is only used in the one spot.
    
    Change-Id: If4227ce7e9d8ef83e3440ac1d9fe2579ed3583e2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134597
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx
index 5613269c2b57..fbceffa5e241 100644
--- a/include/com/sun/star/uno/Any.hxx
+++ b/include/com/sun/star/uno/Any.hxx
@@ -131,31 +131,30 @@ inline Any & Any::operator = ( const Any & rAny )
 
 #if defined LIBO_INTERNAL_ONLY
 
-namespace detail {
-
-inline void moveAnyInternals(Any & from, Any & to) noexcept {
-    uno_any_construct(&to, nullptr, nullptr, &cpp_acquire);
-    std::swap(from.pType, to.pType);
-    std::swap(from.pData, to.pData);
-    std::swap(from.pReserved, to.pReserved);
-    if (to.pData == &from.pReserved) {
-        to.pData = &to.pReserved;
+Any::Any(Any && other) noexcept {
+    uno_any_construct(this, nullptr, nullptr, &cpp_acquire);
+    std::swap(other.pType, pType);
+    std::swap(other.pData, pData);
+    std::swap(other.pReserved, pReserved);
+    if (pData == &other.pReserved) {
+        pData = &pReserved;
     }
-    // This leaves from.pData (where "from" is now VOID) dangling to somewhere 
(cf.
+    // This leaves other.pData (where "other" is now VOID) dangling to 
somewhere (cf.
     // CONSTRUCT_EMPTY_ANY, cppu/source/uno/prim.hxx), but what's relevant is
     // only that it isn't a nullptr (as e.g. >>= -> uno_type_assignData ->
     // _assignData takes a null pSource to mean "construct a default value").
 }
 
-}
-
-Any::Any(Any && other) noexcept {
-    detail::moveAnyInternals(other, *this);
-}
-
 Any & Any::operator =(Any && other) noexcept {
-    uno_any_destruct(this, &cpp_release);
-    detail::moveAnyInternals(other, *this);
+    std::swap(other.pType, pType);
+    std::swap(other.pData, pData);
+    std::swap(other.pReserved, pReserved);
+    if (pData == &other.pReserved) {
+        pData = &pReserved;
+    }
+    if (other.pData == &pReserved) {
+        other.pData = &other.pReserved;
+    }
     return *this;
 }
 

Reply via email to