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

loplugin:useuniqueptr in ScSortInfoArray

just allocate these object inside the vector, we allocate in them in one
big block anyhow, not one at a time

Change-Id: I8df17ce180264efb5f51af2da91918889db4e68b
Reviewed-on: https://gerrit.libreoffice.org/55697Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst f971bdb0
......@@ -253,7 +253,7 @@ public:
explicit Row( size_t nColSize ) : maCells(nColSize, Cell()), mbHidden(false), mbFiltered(false) {}
};
typedef std::vector<Row*> RowsType;
typedef std::vector<Row> RowsType;
private:
std::unique_ptr<RowsType> mpRows; /// row-wise data table for sort by row operation.
......@@ -290,12 +290,6 @@ public:
maOrderIndices.push_back(i+nStart);
}
~ScSortInfoArray()
{
if (mpRows)
std::for_each(mpRows->begin(), mpRows->end(), std::default_delete<Row>());
}
void SetKeepQuery( bool b ) { mbKeepQuery = b; }
bool IsKeepQuery() const { return mbKeepQuery; }
......@@ -325,6 +319,8 @@ public:
*/
void Swap( SCCOLROW nInd1, SCCOLROW nInd2 )
{
if (nInd1 == nInd2) // avoid self-move-assign
return;
SCSIZE n1 = static_cast<SCSIZE>(nInd1 - nStart);
SCSIZE n2 = static_cast<SCSIZE>(nInd2 - nStart);
for ( sal_uInt16 nSort = 0; nSort < static_cast<sal_uInt16>(mvppInfo.size()); nSort++ )
......@@ -387,10 +383,7 @@ public:
RowsType& InitDataRows( size_t nRowSize, size_t nColSize )
{
mpRows.reset(new RowsType);
mpRows->reserve(nRowSize);
for (size_t i = 0; i < nRowSize; ++i)
mpRows->push_back(new Row(nColSize));
mpRows->resize(nRowSize, Row(nColSize));
return *mpRows;
}
......@@ -426,7 +419,7 @@ void initDataRows(
for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
{
ScSortInfoArray::Row& rRow = *rRows[nRow-nRow1];
ScSortInfoArray::Row& rRow = rRows[nRow-nRow1];
ScSortInfoArray::Cell& rCell = rRow.maCells[nCol-nCol1];
rCell.maCell = rCol.GetCellValue(aBlockPos, nRow);
rCell.mpAttr = rCol.GetCellTextAttr(aBlockPos, nRow);
......@@ -443,7 +436,7 @@ void initDataRows(
{
for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
{
ScSortInfoArray::Row& rRow = *rRows[nRow-nRow1];
ScSortInfoArray::Row& rRow = rRows[nRow-nRow1];
rRow.mbHidden = rTab.RowHidden(nRow);
rRow.mbFiltered = rTab.RowFiltered(nRow);
}
......@@ -700,12 +693,12 @@ void fillSortedColumnArray(
for (size_t i = 0; i < pRows->size(); ++i)
{
ScSortInfoArray::Row* pRow = (*pRows)[i];
for (size_t j = 0; j < pRow->maCells.size(); ++j)
ScSortInfoArray::Row& rRow = (*pRows)[i];
for (size_t j = 0; j < rRow.maCells.size(); ++j)
{
ScAddress aCellPos(nCol1 + j, nRow1 + i, nTab);
ScSortInfoArray::Cell& rCell = pRow->maCells[j];
ScSortInfoArray::Cell& rCell = rRow.maCells[j];
sc::CellStoreType& rCellStore = aSortedCols.at(j).get()->maCells;
switch (rCell.maCell.meType)
......@@ -799,8 +792,8 @@ void fillSortedColumnArray(
{
// Hidden and filtered flags are first converted to segments.
SCROW nRow = nRow1 + i;
aRowFlags.setRowHidden(nRow, pRow->mbHidden);
aRowFlags.setRowFiltered(nRow, pRow->mbFiltered);
aRowFlags.setRowHidden(nRow, rRow.mbHidden);
aRowFlags.setRowFiltered(nRow, rRow.mbFiltered);
}
if (pProgress)
......
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