Kaydet (Commit) b64f4847 authored tarafından Noel Grandin's avatar Noel Grandin

std::list is overkill for small structures

Change-Id: I483ac562eb709d00c3354006da6662122777fbdc
Reviewed-on: https://gerrit.libreoffice.org/59452
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d4f7fc2a
...@@ -553,24 +553,22 @@ void ScXMLChangeTrackingImportHelper::SetDeletionDependencies(ScMyDelAction* pAc ...@@ -553,24 +553,22 @@ void ScXMLChangeTrackingImportHelper::SetDeletionDependencies(ScMyDelAction* pAc
OSL_ENSURE(((pAction->nActionType == SC_CAT_DELETE_COLS) || OSL_ENSURE(((pAction->nActionType == SC_CAT_DELETE_COLS) ||
(pAction->nActionType == SC_CAT_DELETE_ROWS) || (pAction->nActionType == SC_CAT_DELETE_ROWS) ||
(pAction->nActionType == SC_CAT_DELETE_TABS)), "wrong action type"); (pAction->nActionType == SC_CAT_DELETE_TABS)), "wrong action type");
ScMyMoveCutOffs::iterator aItr(pAction->aMoveCutOffs.begin()); for (const ScMyMoveCutOff & rCutOff : pAction->aMoveCutOffs)
ScMyMoveCutOffs::iterator aEndItr(pAction->aMoveCutOffs.end());
while(aItr != aEndItr)
{ {
ScChangeAction* pChangeAction = pTrack->GetAction(aItr->nID); ScChangeAction* pChangeAction = pTrack->GetAction(rCutOff.nID);
if (pChangeAction && (pChangeAction->GetType() == SC_CAT_MOVE)) if (pChangeAction && (pChangeAction->GetType() == SC_CAT_MOVE))
{ {
ScChangeActionMove* pMoveAction = static_cast<ScChangeActionMove*>(pChangeAction); ScChangeActionMove* pMoveAction = static_cast<ScChangeActionMove*>(pChangeAction);
if (pMoveAction && pDelAct) if (pMoveAction && pDelAct)
pDelAct->AddCutOffMove(pMoveAction, static_cast<sal_Int16>(aItr->nStartPosition), pDelAct->AddCutOffMove(pMoveAction, static_cast<sal_Int16>(rCutOff.nStartPosition),
static_cast<sal_Int16>(aItr->nEndPosition)); static_cast<sal_Int16>(rCutOff.nEndPosition));
} }
else else
{ {
OSL_FAIL("no cut off move action"); OSL_FAIL("no cut off move action");
} }
aItr = pAction->aMoveCutOffs.erase(aItr);
} }
pAction->aMoveCutOffs.clear();
} }
} }
...@@ -625,13 +623,11 @@ void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction) ...@@ -625,13 +623,11 @@ void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction)
{ {
if (!pAction->aDependencies.empty()) if (!pAction->aDependencies.empty())
{ {
ScMyDependencies::iterator aItr(pAction->aDependencies.begin()); for (const auto & rID : pAction->aDependencies)
ScMyDependencies::iterator aEndItr(pAction->aDependencies.end());
while(aItr != aEndItr)
{ {
pAct->AddDependent(*aItr, pTrack); pAct->AddDependent(rID, pTrack);
aItr = pAction->aDependencies.erase(aItr);
} }
pAction->aDependencies.clear();
} }
if (!pAction->aDeletedList.empty()) if (!pAction->aDeletedList.empty())
{ {
...@@ -758,8 +754,8 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc) ...@@ -758,8 +754,8 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc)
// old files didn't store nanoseconds, disable until encountered // old files didn't store nanoseconds, disable until encountered
pTrack->SetTimeNanoSeconds( false ); pTrack->SetTimeNanoSeconds( false );
ScMyActions::iterator aItr(aActions.begin()); auto aItr(aActions.begin());
ScMyActions::iterator aEndItr(aActions.end()); auto aEndItr(aActions.end());
while (aItr != aEndItr) while (aItr != aEndItr)
{ {
ScChangeAction* pAction = nullptr; ScChangeAction* pAction = nullptr;
......
...@@ -96,8 +96,6 @@ struct ScMyMoveCutOff ...@@ -96,8 +96,6 @@ struct ScMyMoveCutOff
nID(nTempID), nStartPosition(nStartPos), nEndPosition(nEndPos) {} nID(nTempID), nStartPosition(nStartPos), nEndPosition(nEndPos) {}
}; };
typedef std::list<ScMyMoveCutOff> ScMyMoveCutOffs;
struct ScMyMoveRanges struct ScMyMoveRanges
{ {
ScBigRange aSourceRange; ScBigRange aSourceRange;
...@@ -107,13 +105,11 @@ struct ScMyMoveRanges ...@@ -107,13 +105,11 @@ struct ScMyMoveRanges
aSourceRange(rSource), aTargetRange(rTarget) {} aSourceRange(rSource), aTargetRange(rTarget) {}
}; };
typedef std::list<sal_uInt32> ScMyDependencies;
struct ScMyBaseAction struct ScMyBaseAction
{ {
ScMyActionInfo aInfo; ScMyActionInfo aInfo;
ScBigRange aBigRange; ScBigRange aBigRange;
ScMyDependencies aDependencies; std::deque<sal_uInt32> aDependencies;
std::deque<ScMyDeleted> aDeletedList; std::deque<ScMyDeleted> aDeletedList;
sal_uInt32 nActionNumber; sal_uInt32 nActionNumber;
sal_uInt32 nRejectingNumber; sal_uInt32 nRejectingNumber;
...@@ -135,7 +131,7 @@ struct ScMyDelAction : public ScMyBaseAction ...@@ -135,7 +131,7 @@ struct ScMyDelAction : public ScMyBaseAction
{ {
std::deque<ScMyGenerated> aGeneratedList; std::deque<ScMyGenerated> aGeneratedList;
std::unique_ptr<ScMyInsertionCutOff> pInsCutOff; std::unique_ptr<ScMyInsertionCutOff> pInsCutOff;
ScMyMoveCutOffs aMoveCutOffs; std::deque<ScMyMoveCutOff> aMoveCutOffs;
sal_Int32 nD; sal_Int32 nD;
explicit ScMyDelAction(const ScChangeActionType nActionType); explicit ScMyDelAction(const ScChangeActionType nActionType);
...@@ -165,12 +161,10 @@ struct ScMyRejAction : public ScMyBaseAction ...@@ -165,12 +161,10 @@ struct ScMyRejAction : public ScMyBaseAction
virtual ~ScMyRejAction() override; virtual ~ScMyRejAction() override;
}; };
typedef std::list<ScMyBaseAction*> ScMyActions;
class ScXMLChangeTrackingImportHelper class ScXMLChangeTrackingImportHelper
{ {
std::set<OUString> aUsers; std::set<OUString> aUsers;
ScMyActions aActions; std::deque<ScMyBaseAction*> aActions;
css::uno::Sequence<sal_Int8> aProtect; css::uno::Sequence<sal_Int8> aProtect;
ScDocument* pDoc; ScDocument* pDoc;
ScChangeTrack* pTrack; ScChangeTrack* pTrack;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment