From b64f4847cceef666ba3c86950df729f3c94a1bd9 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 22 Aug 2018 15:18:56 +0200 Subject: std::list is overkill for small structures Change-Id: I483ac562eb709d00c3354006da6662122777fbdc Reviewed-on: https://gerrit.libreoffice.org/59452 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../filter/xml/XMLChangeTrackingImportHelper.cxx | 24 +++++++++------------- .../filter/xml/XMLChangeTrackingImportHelper.hxx | 12 +++-------- 2 files changed, 13 insertions(+), 23 deletions(-) (limited to 'sc') 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(pChangeAction); if (pMoveAction && pDelAct) - pDelAct->AddCutOffMove(pMoveAction, static_cast(aItr->nStartPosition), - static_cast(aItr->nEndPosition)); + pDelAct->AddCutOffMove(pMoveAction, static_cast(rCutOff.nStartPosition), + static_cast(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 ScMyMoveCutOffs; - struct ScMyMoveRanges { ScBigRange aSourceRange; @@ -107,13 +105,11 @@ struct ScMyMoveRanges aSourceRange(rSource), aTargetRange(rTarget) {} }; -typedef std::list ScMyDependencies; - struct ScMyBaseAction { ScMyActionInfo aInfo; ScBigRange aBigRange; - ScMyDependencies aDependencies; + std::deque aDependencies; std::deque aDeletedList; sal_uInt32 nActionNumber; sal_uInt32 nRejectingNumber; @@ -135,7 +131,7 @@ struct ScMyDelAction : public ScMyBaseAction { std::deque aGeneratedList; std::unique_ptr pInsCutOff; - ScMyMoveCutOffs aMoveCutOffs; + std::deque aMoveCutOffs; sal_Int32 nD; explicit ScMyDelAction(const ScChangeActionType nActionType); @@ -165,12 +161,10 @@ struct ScMyRejAction : public ScMyBaseAction virtual ~ScMyRejAction() override; }; -typedef std::list ScMyActions; - class ScXMLChangeTrackingImportHelper { std::set aUsers; - ScMyActions aActions; + std::deque aActions; css::uno::Sequence aProtect; ScDocument* pDoc; ScChangeTrack* pTrack; -- cgit