summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-18 20:57:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-20 09:40:38 +0200
commit084b2b068ad6729775f7fa5965429fc5cc3c2ae3 (patch)
tree048be7e86e5b9b1f5422146545e1311e65fff382
parent0874486b348f1477d59e161a4d73c5cb56e238f9 (diff)
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.grandin@collabora.co.uk>
-rw-r--r--include/com/sun/star/uno/Any.hxx35
1 files changed, 17 insertions, 18 deletions
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;
}