summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-10 16:43:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-11 08:41:44 +0100
commit9e2ca20b0514cc77102c9985ad72f242c0af910e (patch)
tree68c3a58c1a1d19280c9d90473d930ae9316a3bf5 /sw
parent9fd69aba34f9818ac760f5704e007b92679d65b1 (diff)
no need to allocate on heap in SwUndoSortList
Change-Id: I949a9d32b18d5ccae17dee26f030173307d0b3fb Reviewed-on: https://gerrit.libreoffice.org/66121 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/inc/UndoSort.hxx2
-rw-r--r--sw/source/core/undo/unsort.cxx24
2 files changed, 10 insertions, 16 deletions
diff --git a/sw/source/core/inc/UndoSort.hxx b/sw/source/core/inc/UndoSort.hxx
index 167aaa4ef625..27f97ceaf995 100644
--- a/sw/source/core/inc/UndoSort.hxx
+++ b/sw/source/core/inc/UndoSort.hxx
@@ -57,8 +57,6 @@ struct SwSortUndoElement
~SwSortUndoElement();
};
-typedef std::vector<SwNodeIndex*> SwUndoSortList;
-
class SwUndoSort : public SwUndo, private SwUndRng
{
std::unique_ptr<SwSortOptions> pSortOpt;
diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx
index ac354d889be4..b20d4e5b94a2 100644
--- a/sw/source/core/undo/unsort.cxx
+++ b/sw/source/core/undo/unsort.cxx
@@ -121,7 +121,8 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
// create index for (sorted) positions
// The IndexList must be created based on (asc.) sorted SourcePosition.
- SwUndoSortList aIdxList;
+ std::vector<SwNodeIndex> aIdxList;
+ aIdxList.reserve(m_SortList.size());
for (size_t i = 0; i < m_SortList.size(); ++i)
{
@@ -129,9 +130,8 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
{
if (j->SORT_TXT_TBL.TXT.nSource == nSttNode + i)
{
- SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(),
- j->SORT_TXT_TBL.TXT.nTarget );
- aIdxList.insert( aIdxList.begin() + i, pIdx );
+ aIdxList.push_back( SwNodeIndex( rDoc.GetNodes(),
+ j->SORT_TXT_TBL.TXT.nTarget ) );
break;
}
}
@@ -140,13 +140,11 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
for (size_t i = 0; i < m_SortList.size(); ++i)
{
SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i );
- SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
+ SwNodeRange aRg( aIdxList[i], 0, aIdxList[i], 1 );
rDoc.getIDocumentContentOperations().MoveNodeRange(aRg, aIdx,
SwMoveFlags::DEFAULT);
}
// delete indices
- for(auto& rpIdx : aIdxList)
- delete rpIdx;
aIdxList.clear();
SetPaM(rPam, true);
}
@@ -203,25 +201,23 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
SetPaM(rPam);
RemoveIdxFromRange(rPam, true);
- SwUndoSortList aIdxList;
+ std::vector<SwNodeIndex> aIdxList;
+ aIdxList.reserve(m_SortList.size());
for (size_t i = 0; i < m_SortList.size(); ++i)
{ // current position is starting point
- SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(),
- m_SortList[i]->SORT_TXT_TBL.TXT.nSource);
- aIdxList.insert( aIdxList.begin() + i, pIdx );
+ aIdxList.push_back( SwNodeIndex( rDoc.GetNodes(),
+ m_SortList[i]->SORT_TXT_TBL.TXT.nSource) );
}
for (size_t i = 0; i < m_SortList.size(); ++i)
{
SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i);
- SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
+ SwNodeRange aRg( aIdxList[i], 0, aIdxList[i], 1 );
rDoc.getIDocumentContentOperations().MoveNodeRange(aRg, aIdx,
SwMoveFlags::DEFAULT);
}
// delete indices
- for(auto& rpIdx : aIdxList)
- delete rpIdx;
aIdxList.clear();
SetPaM(rPam, true);
SwTextNode const*const pTNd = rPam.GetNode().GetTextNode();