diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-01 16:03:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-02 11:56:45 +0200 |
commit | b392d0a25e229f305497ab5f9f084b71b24cc387 (patch) | |
tree | 41df3434451c4c139fadb6dd4491b02796d3dbdc /include/svl/sharedstring.hxx | |
parent | 3869673f95fce5e83c9d5d9eaf08f21f36ad0bd6 (diff) |
tdf#150712 reduce cost of SharedString::getString
where the construction of empty strings is significant here
which required fixing a couple of places that ended up using
a reference to a temporary.
Change-Id: I52feb1673bd39db4060585ac8d9ae2f3dea27fc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139210
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/svl/sharedstring.hxx')
-rw-r--r-- | include/svl/sharedstring.hxx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx index 5b5c35b95a92..d84b5a16a2c9 100644 --- a/include/svl/sharedstring.hxx +++ b/include/svl/sharedstring.hxx @@ -22,6 +22,7 @@ class SVL_DLLPUBLIC SharedString public: static const SharedString & getEmptyString(); + static const OUString EMPTY_STRING; SharedString(); SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase ); @@ -36,7 +37,7 @@ public: bool operator== ( const SharedString& r ) const; bool operator!= ( const SharedString& r ) const; - OUString getString() const; + const OUString & getString() const; rtl_uString* getData(); const rtl_uString* getData() const; @@ -111,9 +112,9 @@ inline bool SharedString::operator!= ( const SharedString& r ) const return !operator== (r); } -inline OUString SharedString::getString() const +inline const OUString & SharedString::getString() const { - return mpData ? OUString(mpData) : OUString(); + return mpData ? OUString::unacquired(&mpData) : EMPTY_STRING; } inline rtl_uString* SharedString::getData() |