From 9db70dfdc8d1851415f9d90fc192551178973f43 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 31 Oct 2019 08:07:08 +0200 Subject: tdf#125688, deque->vector shaves 5% off load time Change-Id: I555ce09d12f801c9d69efb816f9389e27ca396cc Reviewed-on: https://gerrit.libreoffice.org/81818 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../filter/xml/XMLChangeTrackingImportHelper.cxx | 20 ++++++++++---------- .../filter/xml/XMLChangeTrackingImportHelper.hxx | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index a7f141c832f8..a9a7cb3f126c 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -267,12 +267,12 @@ void ScXMLChangeTrackingImportHelper::SetPosition(const sal_Int32 nPosition, con void ScXMLChangeTrackingImportHelper::AddDeleted(const sal_uInt32 nID) { - pCurrentAction->aDeletedList.emplace_front( nID, nullptr ); + pCurrentAction->aDeletedList.emplace_back( nID, nullptr ); } void ScXMLChangeTrackingImportHelper::AddDeleted(const sal_uInt32 nID, std::unique_ptr pCellInfo) { - pCurrentAction->aDeletedList.emplace_front( nID, std::move(pCellInfo) ); + pCurrentAction->aDeletedList.emplace_back( nID, std::move(pCellInfo) ); } void ScXMLChangeTrackingImportHelper::SetMultiSpanned(const sal_Int16 nTempMultiSpanned) @@ -304,7 +304,7 @@ void ScXMLChangeTrackingImportHelper::AddMoveCutOff(const sal_uInt32 nID, const if ((pCurrentAction->nActionType == SC_CAT_DELETE_COLS) || (pCurrentAction->nActionType == SC_CAT_DELETE_ROWS)) { - static_cast(pCurrentAction.get())->aMoveCutOffs.push_front(ScMyMoveCutOff(nID, nStartPosition, nEndPosition)); + static_cast(pCurrentAction.get())->aMoveCutOffs.push_back(ScMyMoveCutOff(nID, nStartPosition, nEndPosition)); } else { @@ -478,7 +478,7 @@ std::unique_ptr ScXMLChangeTrackingImportHelper::CreateContentAc pAction->aBigRange, aUser, aDateTime, sComment, aCell, pDoc, sInputString); } -void ScXMLChangeTrackingImportHelper::CreateGeneratedActions(std::deque& rList) +void ScXMLChangeTrackingImportHelper::CreateGeneratedActions(std::vector& rList) { for (ScMyGenerated & rGenerated : rList) { @@ -536,8 +536,9 @@ 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"); - for (const ScMyMoveCutOff & rCutOff : pAction->aMoveCutOffs) + for (auto it = pAction->aMoveCutOffs.crbegin(); it != pAction->aMoveCutOffs.crend(); ++it) { + const ScMyMoveCutOff & rCutOff = *it; ScChangeAction* pChangeAction = pTrack->GetAction(rCutOff.nID); if (pChangeAction && (pChangeAction->GetType() == SC_CAT_MOVE)) { @@ -602,16 +603,15 @@ void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction) { if (!pAction->aDependencies.empty()) { - for (const auto & rID : pAction->aDependencies) - { - pAct->AddDependent(rID, pTrack); - } + for (auto it = pAction->aDependencies.crbegin(); it != pAction->aDependencies.crend(); ++it) + pAct->AddDependent(*it, pTrack); pAction->aDependencies.clear(); } if (!pAction->aDeletedList.empty()) { - for(const ScMyDeleted & rDeleted : pAction->aDeletedList) + for (auto it = pAction->aDeletedList.crbegin(); it != pAction->aDeletedList.crend(); ++it) { + const ScMyDeleted & rDeleted = *it; pAct->SetDeletedInThis(rDeleted.nID, pTrack); ScChangeAction* pDeletedAct = pTrack->GetAction(rDeleted.nID); if ((pDeletedAct->GetType() == SC_CAT_CONTENT) && rDeleted.pCellInfo) diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx index 75f1c9d6e56e..0fc08a705703 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx @@ -108,8 +108,8 @@ struct ScMyBaseAction { ScMyActionInfo aInfo; ScBigRange aBigRange; - std::deque aDependencies; - std::deque aDeletedList; + std::vector aDependencies; + std::vector aDeletedList; sal_uInt32 nActionNumber; sal_uInt32 nRejectingNumber; sal_uInt32 nPreviousAction; @@ -128,9 +128,9 @@ struct ScMyInsAction : public ScMyBaseAction struct ScMyDelAction : public ScMyBaseAction { - std::deque aGeneratedList; + std::vector aGeneratedList; std::unique_ptr pInsCutOff; - std::deque aMoveCutOffs; + std::vector aMoveCutOffs; sal_Int32 nD; explicit ScMyDelAction(const ScChangeActionType nActionType); @@ -139,7 +139,7 @@ struct ScMyDelAction : public ScMyBaseAction struct ScMyMoveAction : public ScMyBaseAction { - std::deque aGeneratedList; + std::vector aGeneratedList; std::unique_ptr pMoveRanges; ScMyMoveAction(); @@ -163,7 +163,7 @@ struct ScMyRejAction : public ScMyBaseAction class ScXMLChangeTrackingImportHelper { std::set aUsers; - std::deque> aActions; + std::vector> aActions; css::uno::Sequence aProtect; ScDocument* pDoc; ScChangeTrack* pTrack; @@ -179,7 +179,7 @@ private: std::unique_ptr CreateRejectionAction(const ScMyRejAction* pAction); std::unique_ptr CreateContentAction(const ScMyContentAction* pAction); - void CreateGeneratedActions(std::deque& rList); + void CreateGeneratedActions(std::vector& rList); public: ScXMLChangeTrackingImportHelper(); @@ -197,7 +197,7 @@ public: void SetBigRange(const ScBigRange& aBigRange) { pCurrentAction->aBigRange = aBigRange; } void SetPreviousChange(const sal_uInt32 nPreviousAction, ScMyCellInfo* pCellInfo); void SetPosition(const sal_Int32 nPosition, const sal_Int32 nCount, const sal_Int32 nTable); - void AddDependence(const sal_uInt32 nID) { pCurrentAction->aDependencies.push_front(nID); } + void AddDependence(const sal_uInt32 nID) { pCurrentAction->aDependencies.push_back(nID); } void AddDeleted(const sal_uInt32 nID); void AddDeleted(const sal_uInt32 nID, std::unique_ptr pCellInfo); void SetMultiSpanned(const sal_Int16 nMultiSpanned); -- cgit