make SharedString move operator= inline (tdf#126109)
Calc uses SharedString in mdds::multi_type_vector, which may move
contents of its blocks on some operations, and making this inline
makes such operations faster.
Change-Id: I67d14639cf253c56b8cca5b2837bb06bc9afd7d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134339
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx
index 050bd8d..5b5c35b 100644
--- a/include/svl/sharedstring.hxx
+++ b/include/svl/sharedstring.hxx
@@ -88,6 +88,24 @@ inline SharedString::~SharedString()
rtl_uString_release(mpDataIgnoreCase);
}
inline SharedString& SharedString::operator=(SharedString&& r) noexcept
{
// Having this inline helps Calc's mdds::multi_type_vector to do some operations
// much faster.
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;
}
inline bool SharedString::operator!= ( const SharedString& r ) const
{
return !operator== (r);
diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx
index e1f2d4f..1bb05c6 100644
--- a/svl/source/misc/sharedstring.cxx
+++ b/svl/source/misc/sharedstring.cxx
@@ -43,22 +43,6 @@ SharedString& SharedString::operator= ( const SharedString& r )
return *this;
}
SharedString& SharedString::operator=(SharedString&& r) noexcept
{
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;
}
bool SharedString::operator== ( const SharedString& r ) const
{
// Compare only the original (not case-folded) string.