diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-05-15 11:59:35 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-05-16 09:04:24 +0200 |
commit | b8aa4d7caf82903b3ba1ff45483756db6835cc60 (patch) | |
tree | a9bb802f1c1328d6673ae6be0d9f6551025d4bca | |
parent | optimise common case of reading a single-pass PNG (diff) | |
download | core-b8aa4d7caf82903b3ba1ff45483756db6835cc60.tar.gz core-b8aa4d7caf82903b3ba1ff45483756db6835cc60.zip |
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>
-rw-r--r-- | include/svl/sharedstring.hxx | 18 | ||||
-rw-r--r-- | svl/source/misc/sharedstring.cxx | 16 |
2 files changed, 18 insertions, 16 deletions
diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx index 050bd8dd9e55..5b5c35b95a92 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 e1f2d4feed0f..1bb05c6ace50 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. |