include/svl/sharedstring.hxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 964eb2f1dd24d68bd1d6caf8d0f349305a2642ec
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Jun 15 10:47:51 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Jun 15 14:17:13 2022 +0200

    Revert "simplify SharedString::operator=(&&)"
    
    This reverts commit 2da1cdd31312a70f205f29bb4dfcbc1771409aa4.
    
    Comment from llunak:
    I'm possibly not remembering it exactly. But the point is that if you're 
going to destroy something, it's faster to destroy it outright rather than move 
it somewhere and destroy it later. If you google it you'll find posts on how 
implementing std::move() using std:swap() is generally a pessimisation.
    
    Change-Id: Ice4234ad074cd894a25782e9c52b34c5acb26c8f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135880
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx
index cef5e410e2cf..5b5c35b95a92 100644
--- a/include/svl/sharedstring.hxx
+++ b/include/svl/sharedstring.hxx
@@ -92,8 +92,16 @@ inline SharedString& SharedString::operator=(SharedString&& 
r) noexcept
 {
     // Having this inline helps Calc's mdds::multi_type_vector to do some 
operations
     // much faster.
-    std::swap(mpData, r.mpData);
-    std::swap(mpDataIgnoreCase, r.mpDataIgnoreCase);
+    if (mpData)
+        rtl_uString_release(mpData);
+    if (mpDataIgnoreCase)
+        rtl_uString_release(mpDataIgnoreCase);
+
+    mpData = r.mpData;
+    mpDataIgnoreCase = r.mpDataIgnoreCase;
+
+    r.mpData = nullptr;
+    r.mpDataIgnoreCase = nullptr;
 
     return *this;
 }

Reply via email to