sc/source/core/tool/cellform.cxx |   15 +++++++++------
 sc/source/core/tool/interpr1.cxx |    5 +++--
 2 files changed, 12 insertions(+), 8 deletions(-)

New commits:
commit b52fd544b9c128d3e28de6355286f6480b618e93
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Sep 20 15:48:38 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Sep 20 22:22:14 2022 +0200

    avoid some string refcounting with sheets with lots of conditional 
formatting
    
    Change-Id: Ibb2de1aa28a57748bede6085074f60af757ae5ef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140244
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 3da99aec0b2f..9d1a73192923 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -146,12 +146,15 @@ OUString ScCellFormat::GetInputString(
         break;
         case CELLTYPE_FORMULA:
         {
-            OUString str;
+            std::optional<OUString> str;
             ScFormulaCell* pFC = rCell.getFormula();
             if (pFC->IsEmptyDisplayedAsString())
                 ; // empty
             else if (pFC->IsValue())
-                rFormatter.GetInputLineString(pFC->GetValue(), nFormat, str, 
bFiltering, bForceSystemLocale);
+            {
+                str.emplace();
+                rFormatter.GetInputLineString(pFC->GetValue(), nFormat, *str, 
bFiltering, bForceSystemLocale);
+            }
             else
             {
                 const svl::SharedString& shared = pFC->GetString();
@@ -166,19 +169,19 @@ OUString ScCellFormat::GetInputString(
             const FormulaError nErrCode = pFC->GetErrCode();
             if (nErrCode != FormulaError::NONE)
             {
-                str.clear();
+                str.reset();
                 if( pShared != nullptr )
                     *pShared = nullptr;
             }
 
-            return str;
+            return str ? std::move(*str) : svl::SharedString::EMPTY_STRING;
         }
         case CELLTYPE_NONE:
             if( pShared != nullptr )
                 *pShared = &svl::SharedString::getEmptyString();
-            return OUString();
+            return svl::SharedString::EMPTY_STRING;
         default:
-            return OUString();
+            return svl::SharedString::EMPTY_STRING;
     }
 }
 
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index a8b55d73d90a..cfaa72dbb978 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8178,7 +8178,8 @@ void ScInterpreter::ScIndirect()
         bTryXlA1 = false;
     }
 
-    OUString sRefStr = GetString().getString();
+    svl::SharedString sSharedRefStr = GetString();
+    const OUString & sRefStr = sSharedRefStr.getString();
     if (sRefStr.isEmpty())
     {
         // Bail out early for empty cells, rely on "we do have a string" below.
@@ -8223,7 +8224,7 @@ void ScInterpreter::ScIndirect()
 
     do
     {
-        OUString aName( ScGlobal::getCharClass().uppercase( sRefStr));
+        const OUString & aName( sSharedRefStr.getDataIgnoreCase() );
         ScDBCollection::NamedDBs& rDBs = 
mrDoc.GetDBCollection()->getNamedDBs();
         const ScDBData* pData = rDBs.findByUpperName( aName);
         if (!pData)

Reply via email to