sc/source/core/tool/editutil.cxx |    5 +++++
 1 file changed, 5 insertions(+)

New commits:
commit b692c8a2809666012084b9e25242c382d7323f72
Author:     Noel Grandin <n...@peralex.com>
AuthorDate: Fri Nov 19 15:07:21 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Nov 20 06:39:53 2021 +0100

    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.gran...@collabora.co.uk>

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++)
     {

Reply via email to