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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 23 16:57:58 UTC 2018


 sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx |   24 +++++++----------
 sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx |   12 ++------
 2 files changed, 13 insertions(+), 23 deletions(-)

New commits:
commit b64f4847cceef666ba3c86950df729f3c94a1bd9
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 22 15:18:56 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Aug 23 18:57:35 2018 +0200

    std::list is overkill for small structures
    
    Change-Id: I483ac562eb709d00c3354006da6662122777fbdc
    Reviewed-on: https://gerrit.libreoffice.org/59452
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
index ca86e272820e..e44932d2203b 100644
--- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
@@ -553,24 +553,22 @@ void ScXMLChangeTrackingImportHelper::SetDeletionDependencies(ScMyDelAction* pAc
         OSL_ENSURE(((pAction->nActionType == SC_CAT_DELETE_COLS) ||
             (pAction->nActionType == SC_CAT_DELETE_ROWS) ||
             (pAction->nActionType == SC_CAT_DELETE_TABS)), "wrong action type");
-        ScMyMoveCutOffs::iterator aItr(pAction->aMoveCutOffs.begin());
-        ScMyMoveCutOffs::iterator aEndItr(pAction->aMoveCutOffs.end());
-        while(aItr != aEndItr)
+        for (const ScMyMoveCutOff & rCutOff : pAction->aMoveCutOffs)
         {
-            ScChangeAction* pChangeAction = pTrack->GetAction(aItr->nID);
+            ScChangeAction* pChangeAction = pTrack->GetAction(rCutOff.nID);
             if (pChangeAction && (pChangeAction->GetType() == SC_CAT_MOVE))
             {
                 ScChangeActionMove* pMoveAction = static_cast<ScChangeActionMove*>(pChangeAction);
                 if (pMoveAction && pDelAct)
-                    pDelAct->AddCutOffMove(pMoveAction, static_cast<sal_Int16>(aItr->nStartPosition),
-                                        static_cast<sal_Int16>(aItr->nEndPosition));
+                    pDelAct->AddCutOffMove(pMoveAction, static_cast<sal_Int16>(rCutOff.nStartPosition),
+                                        static_cast<sal_Int16>(rCutOff.nEndPosition));
             }
             else
             {
                 OSL_FAIL("no cut off move action");
             }
-            aItr = pAction->aMoveCutOffs.erase(aItr);
         }
+        pAction->aMoveCutOffs.clear();
     }
 }
 
@@ -625,13 +623,11 @@ void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction)
     {
         if (!pAction->aDependencies.empty())
         {
-            ScMyDependencies::iterator aItr(pAction->aDependencies.begin());
-            ScMyDependencies::iterator aEndItr(pAction->aDependencies.end());
-            while(aItr != aEndItr)
+            for (const auto & rID : pAction->aDependencies)
             {
-                pAct->AddDependent(*aItr, pTrack);
-                aItr = pAction->aDependencies.erase(aItr);
+                pAct->AddDependent(rID, pTrack);
             }
+            pAction->aDependencies.clear();
         }
         if (!pAction->aDeletedList.empty())
         {
@@ -758,8 +754,8 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc)
         // old files didn't store nanoseconds, disable until encountered
         pTrack->SetTimeNanoSeconds( false );
 
-        ScMyActions::iterator aItr(aActions.begin());
-        ScMyActions::iterator aEndItr(aActions.end());
+        auto aItr(aActions.begin());
+        auto aEndItr(aActions.end());
         while (aItr != aEndItr)
         {
             ScChangeAction* pAction = nullptr;
diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx
index 558eee4289fa..deeb12a6674d 100644
--- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx
+++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx
@@ -96,8 +96,6 @@ struct ScMyMoveCutOff
             nID(nTempID), nStartPosition(nStartPos), nEndPosition(nEndPos) {}
 };
 
-typedef std::list<ScMyMoveCutOff> ScMyMoveCutOffs;
-
 struct ScMyMoveRanges
 {
     ScBigRange aSourceRange;
@@ -107,13 +105,11 @@ struct ScMyMoveRanges
             aSourceRange(rSource), aTargetRange(rTarget) {}
 };
 
-typedef std::list<sal_uInt32> ScMyDependencies;
-
 struct ScMyBaseAction
 {
     ScMyActionInfo aInfo;
     ScBigRange aBigRange;
-    ScMyDependencies aDependencies;
+    std::deque<sal_uInt32> aDependencies;
     std::deque<ScMyDeleted> aDeletedList;
     sal_uInt32 nActionNumber;
     sal_uInt32 nRejectingNumber;
@@ -135,7 +131,7 @@ struct ScMyDelAction : public ScMyBaseAction
 {
     std::deque<ScMyGenerated> aGeneratedList;
     std::unique_ptr<ScMyInsertionCutOff> pInsCutOff;
-    ScMyMoveCutOffs aMoveCutOffs;
+    std::deque<ScMyMoveCutOff> aMoveCutOffs;
     sal_Int32 nD;
 
     explicit ScMyDelAction(const ScChangeActionType nActionType);
@@ -165,12 +161,10 @@ struct ScMyRejAction : public ScMyBaseAction
     virtual ~ScMyRejAction() override;
 };
 
-typedef std::list<ScMyBaseAction*> ScMyActions;
-
 class ScXMLChangeTrackingImportHelper
 {
     std::set<OUString>  aUsers;
-    ScMyActions         aActions;
+    std::deque<ScMyBaseAction*> aActions;
     css::uno::Sequence<sal_Int8> aProtect;
     ScDocument*         pDoc;
     ScChangeTrack*      pTrack;


More information about the Libreoffice-commits mailing list