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

Julien Nabet serval2412 at yahoo.fr
Sun Oct 1 18:07:14 UTC 2017


 sc/inc/macromgr.hxx                |    2 +-
 sc/source/ui/docshell/macromgr.cxx |   31 ++++++++++++++++---------------
 2 files changed, 17 insertions(+), 16 deletions(-)

New commits:
commit 05dbd67f5d7bd6611830fc793985b7d5858bf68c
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Oct 1 13:41:11 2017 +0200

    Replace list by vector in macromgr.cxx (sc)
    
    Change-Id: I5b57d4f4a1e0c68fdc56d84392f4b1472a67e82b
    Reviewed-on: https://gerrit.libreoffice.org/42992
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/sc/inc/macromgr.hxx b/sc/inc/macromgr.hxx
index 9906b55d08f9..02156f155ece 100644
--- a/sc/inc/macromgr.hxx
+++ b/sc/inc/macromgr.hxx
@@ -34,7 +34,7 @@ public:
     SC_DLLPUBLIC bool GetUserFuncVolatile( const OUString& sName );
 
     void AddDependentCell(const OUString& aModuleName, ScFormulaCell* pCell);
-    void RemoveDependentCell(ScFormulaCell* pCell);
+    void RemoveDependentCell(const ScFormulaCell* pCell);
     void BroadcastModuleUpdate(const OUString& aModuleName);
 
 private:
diff --git a/sc/source/ui/docshell/macromgr.cxx b/sc/source/ui/docshell/macromgr.cxx
index 8ca7185a18c5..29e66cc5f1ab 100644
--- a/sc/source/ui/docshell/macromgr.cxx
+++ b/sc/source/ui/docshell/macromgr.cxx
@@ -24,14 +24,13 @@
 #include <cppuhelper/implbase.hxx>
 #include <sfx2/objsh.hxx>
 #include "formulacell.hxx"
+#include <vector>
 #include <com/sun/star/container/XContainer.hpp>
 
-#include <list>
-
 using namespace ::com::sun::star;
 using ::com::sun::star::uno::RuntimeException;
 using ::com::sun::star::uno::Reference;
-using ::std::list;
+using ::std::vector;
 using ::std::pair;
 
 /**
@@ -48,7 +47,7 @@ public:
         if (itr == maCells.end())
         {
             pair<ModuleCellMap::iterator, bool> r = maCells.emplace(
-                rModuleName, list<ScFormulaCell*>());
+                rModuleName, vector<ScFormulaCell*>());
 
             if (!r.second)
                 // insertion failed.
@@ -59,31 +58,33 @@ public:
         itr->second.push_back(pCell);
     }
 
-    void removeCell(ScFormulaCell* pCell)
+    void removeCell(const ScFormulaCell* pCell)
     {
         ModuleCellMap::iterator itr = maCells.begin(), itrEnd = maCells.end();
         for (; itr != itrEnd; ++itr)
-            itr->second.remove(pCell);
+        {
+            itr->second.erase(std::remove(itr->second.begin(), itr->second.end(), pCell), itr->second.end() );
+        }
     }
 
-    void getCellsByModule(const OUString& rModuleName, list<ScFormulaCell*>& rCells)
+    void getCellsByModule(const OUString& rModuleName, vector<ScFormulaCell*>& rCells)
     {
         ModuleCellMap::iterator itr = maCells.find(rModuleName);
         if (itr == maCells.end())
             return;
 
-        list<ScFormulaCell*>& rCellList = itr->second;
+        vector<ScFormulaCell*>& rCellList = itr->second;
 
         // Remove duplicates.
-        rCellList.sort();
-        rCellList.unique();
+        std::sort(rCellList.begin(), rCellList.end());
+        std::unique(rCellList.begin(), rCellList.end());
         // exception safe copy
-        list<ScFormulaCell*> temp(rCellList);
+        vector<ScFormulaCell*> temp(rCellList);
         rCells.swap(temp);
     }
 
 private:
-    typedef std::unordered_map<OUString, list<ScFormulaCell*>, OUStringHash> ModuleCellMap;
+    typedef std::unordered_map<OUString, vector<ScFormulaCell*>, OUStringHash> ModuleCellMap;
     ModuleCellMap maCells;
 };
 
@@ -172,16 +173,16 @@ void ScMacroManager::AddDependentCell(const OUString& aModuleName, ScFormulaCell
     mpDepTracker->addCell(aModuleName, pCell);
 }
 
-void ScMacroManager::RemoveDependentCell(ScFormulaCell* pCell)
+void ScMacroManager::RemoveDependentCell(const ScFormulaCell* pCell)
 {
     mpDepTracker->removeCell(pCell);
 }
 
 void ScMacroManager::BroadcastModuleUpdate(const OUString& aModuleName)
 {
-    list<ScFormulaCell*> aCells;
+    vector<ScFormulaCell*> aCells;
     mpDepTracker->getCellsByModule(aModuleName, aCells);
-    list<ScFormulaCell*>::iterator itr = aCells.begin(), itrEnd = aCells.end();
+    vector<ScFormulaCell*>::iterator itr = aCells.begin(), itrEnd = aCells.end();
     for (; itr != itrEnd; ++itr)
     {
         ScFormulaCell* pCell = *itr;


More information about the Libreoffice-commits mailing list