diff options
author | Noel Grandin <noel@peralex.com> | 2021-11-19 15:07:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-20 06:39:53 +0100 |
commit | b692c8a2809666012084b9e25242c382d7323f72 (patch) | |
tree | dc4e3e889eb11d86129c64cf501d7dbed1e1080a | |
parent | 214fa233338c09156c67f85818b6a2ea6b3235bd (diff) |
small optimisation
avoid malloc in the common case
Change-Id: I3820065c2b070eddf7cfcba117ec1be73735957f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125562
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/source/core/tool/editutil.cxx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx index 3e302192b17a..40957b3362b1 100644 --- a/sc/source/core/tool/editutil.cxx +++ b/sc/source/core/tool/editutil.cxx @@ -73,6 +73,11 @@ OUString ScEditUtil::ModifyDelimiters( const OUString& rOld ) static OUString lcl_GetDelimitedString( const EditEngine& rEngine, const char c ) { sal_Int32 nParCount = rEngine.GetParagraphCount(); + // avoid creating a new string if possible + if (nParCount == 0) + return OUString(); + else if (nParCount == 1) + return rEngine.GetText(0); OUStringBuffer aRet( nParCount * 80 ); for (sal_Int32 nPar=0; nPar<nParCount; nPar++) { |