sc/inc/userlist.hxx              |    3 ++-
 sc/source/core/tool/appoptio.cxx |   12 +++++++-----
 sc/source/core/tool/userlist.cxx |   21 +++++++++------------
 3 files changed, 18 insertions(+), 18 deletions(-)

New commits:
commit 182974354e4536af568dfb05a7400e48a2fe1032
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Jun 4 12:58:46 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Jun 4 14:17:35 2023 +0200

    Optimize ScAppCfg::ReadSortListCfg
    
    Do not initialize defaults when using custom user list.
    
    Change-Id: I8428a20b65182011a25325f0b7298ea51998346b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152587
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx
index 7625ad15f5ee..80968361ceac 100644
--- a/sc/inc/userlist.hxx
+++ b/sc/inc/userlist.hxx
@@ -69,9 +69,10 @@ class SC_DLLPUBLIC ScUserList
     DataType maData;
 
 public:
-    ScUserList();
+    explicit ScUserList(bool initDefault = true);
     ScUserList(const ScUserList& r) = default;
 
+    void AddDefaults();
     void EraseData(size_t nIndex) { maData.erase(maData.cbegin() + nIndex); }
 
     const ScUserListData* GetData(const OUString& rSubStr) const;
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 16a0c4cb9174..9dbc85f310ae 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -407,16 +407,18 @@ void ScAppCfg::ReadSortListCfg()
 
     if (Sequence<OUString> aSeq; aValues[SCSORTLISTOPT_LIST] >>= aSeq)
     {
-        ScUserList aList;
+        ScUserList aList(false); // Do not init defaults
 
-        //  if setting is "default", keep default values from ScUserList ctor
+        //  if setting is "default", keep default values
         //TODO: mark "default" in a safe way
         const bool bDefault = (aSeq.getLength() == 1 && aSeq[0] == "NULL");
 
-        if (!bDefault)
+        if (bDefault)
+        {
+            aList.AddDefaults();
+        }
+        else
         {
-            aList.clear();
-
             for (const OUString& rStr : std::as_const(aSeq))
             {
                 aList.emplace_back(rStr);
diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx
index 4540ad3ea0f6..f38a16d98f12 100644
--- a/sc/source/core/tool/userlist.cxx
+++ b/sc/source/core/tool/userlist.cxx
@@ -200,20 +200,18 @@ sal_Int32 ScUserListData::ICompare(const OUString& 
rSubStr1, const OUString& rSu
         return ScGlobal::GetTransliteration().compareString( rSubStr1, 
rSubStr2 );
 }
 
-ScUserList::ScUserList()
+ScUserList::ScUserList(bool initDefault)
 {
-    using namespace ::com::sun::star;
+    if (initDefault)
+        AddDefaults();
+}
 
+void ScUserList::AddDefaults()
+{
     sal_Unicode cDelimiter = ScGlobal::cListDelimiter;
-    uno::Sequence< i18n::CalendarItem2 > xCal;
-
-    const uno::Sequence< i18n::Calendar2 > xCalendars(
-            ScGlobal::getLocaleData().getAllCalendars() );
-
-    for ( const auto& rCalendar : xCalendars )
+    for (const auto& rCalendar : ScGlobal::getLocaleData().getAllCalendars())
     {
-        xCal = rCalendar.Days;
-        if ( xCal.hasElements() )
+        if (const auto& xCal = rCalendar.Days; xCal.hasElements())
         {
             OUStringBuffer aDayShortBuf(32), aDayLongBuf(64);
             sal_Int32 i;
@@ -244,8 +242,7 @@ ScUserList::ScUserList()
                 emplace_back(aDayLong);
         }
 
-        xCal = rCalendar.Months;
-        if ( xCal.hasElements() )
+        if (const auto& xCal = rCalendar.Months; xCal.hasElements())
         {
             OUStringBuffer aMonthShortBuf(128), aMonthLongBuf(128);
             sal_Int32 i;

Reply via email to