[Libreoffice-commits] core.git: sc/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Sep 4 11:55:43 UTC 2021


 sc/source/filter/xml/xmlimprt.cxx |   12 ++++++------
 sc/source/filter/xml/xmlimprt.hxx |    8 +++-----
 2 files changed, 9 insertions(+), 11 deletions(-)

New commits:
commit dc9f3e074b7139382500be0887caceffb646eed8
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Fri Sep 3 18:57:41 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Sep 4 13:55:10 2021 +0200

    no need to allocate ScMyNamedExpressions with unique_ptr
    
    Change-Id: Ib82404230a0da4865c8c83087bca255811a89ed7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121620
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index b84dd4ff4622..e0ff318fca37 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -391,7 +391,7 @@ ScXMLImport::~ScXMLImport() noexcept
     pStyleNumberFormats.reset();
     pStylesImportHelper.reset();
 
-    m_pMyNamedExpressions.reset();
+    m_aMyNamedExpressions.clear();
     pMyLabelRanges.reset();
     pValidations.reset();
     pDetectiveOpArray.reset();
@@ -581,14 +581,14 @@ void ScXMLImport::AddNamedExpression(SCTAB nTab, ScMyNamedExpression* pNamedExp)
     {
         // No chain exists for this sheet.  Create one.
         ::std::pair<SheetNamedExpMap::iterator, bool> r =
-            m_SheetNamedExpressions.insert(std::make_pair(nTab, std::make_unique<ScMyNamedExpressions>()));
+            m_SheetNamedExpressions.insert(std::make_pair(nTab, ScMyNamedExpressions()));
         if (!r.second)
             // insertion failed.
             return;
 
         itr = r.first;
     }
-    ScMyNamedExpressions& r = *itr->second;
+    ScMyNamedExpressions& r = itr->second;
     r.push_back(std::move(p));
 }
 
@@ -1304,7 +1304,7 @@ public:
 
 void ScXMLImport::SetNamedRanges()
 {
-    if (!m_pMyNamedExpressions)
+    if (m_aMyNamedExpressions.empty())
         return;
 
     if (!pDoc)
@@ -1312,7 +1312,7 @@ void ScXMLImport::SetNamedRanges()
 
     // Insert the namedRanges
     ScRangeName* pRangeNames = pDoc->GetRangeName();
-    ::std::for_each(m_pMyNamedExpressions->begin(), m_pMyNamedExpressions->end(), RangeNameInserter(*pDoc, *pRangeNames));
+    ::std::for_each(m_aMyNamedExpressions.begin(), m_aMyNamedExpressions.end(), RangeNameInserter(*pDoc, *pRangeNames));
 }
 
 void ScXMLImport::SetSheetNamedRanges()
@@ -1327,7 +1327,7 @@ void ScXMLImport::SetSheetNamedRanges()
         if (!pRangeNames)
             continue;
 
-        const ScMyNamedExpressions& rNames = *itr.second;
+        const ScMyNamedExpressions& rNames = itr.second;
         ::std::for_each(rNames.begin(), rNames.end(), RangeNameInserter(*pDoc, *pRangeNames));
     }
 }
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 5c3eec947de7..c585e4b0131d 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -116,7 +116,7 @@ class ScXMLImport: public SvXMLImport
     ScXMLImport(const ScXMLImport&) = delete;
     const ScXMLImport& operator=(const ScXMLImport&) = delete;
 
-    typedef ::std::map<SCTAB, std::unique_ptr<ScMyNamedExpressions>> SheetNamedExpMap;
+    typedef ::std::map<SCTAB, ScMyNamedExpressions> SheetNamedExpMap;
 
     ScDocument*             pDoc;
     std::unique_ptr<ScDocumentImport> mpDocImport;
@@ -140,7 +140,7 @@ class ScXMLImport: public SvXMLImport
 
     std::vector<ScDocRowHeightUpdater::TabRanges> maRecalcRowRanges;
 
-    std::unique_ptr<ScMyNamedExpressions>   m_pMyNamedExpressions;
+    ScMyNamedExpressions   m_aMyNamedExpressions;
     SheetNamedExpMap m_SheetNamedExpressions;
 
     std::unique_ptr<ScMyLabelRanges>            pMyLabelRanges;
@@ -225,9 +225,7 @@ public:
 
     void AddNamedExpression(ScMyNamedExpression* pMyNamedExpression)
     {
-        if (!m_pMyNamedExpressions)
-            m_pMyNamedExpressions.reset(new ScMyNamedExpressions);
-        m_pMyNamedExpressions->push_back(std::unique_ptr<ScMyNamedExpression>(pMyNamedExpression));
+        m_aMyNamedExpressions.push_back(std::unique_ptr<ScMyNamedExpression>(pMyNamedExpression));
     }
 
     void AddNamedExpression(SCTAB nTab, ScMyNamedExpression* pNamedExp);


More information about the Libreoffice-commits mailing list