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

reduce some unnecessary ScRangeList copying

and reduce unnecessary work in ScRangeList

Change-Id: I0ee767fe28571f75f8a2ff980cea27c97c9797dc
Reviewed-on: https://gerrit.libreoffice.org/54705Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 2a93d2a4
......@@ -5087,7 +5087,7 @@ void ScDocument::GetSelectionFrame( const ScMarkData& rMark,
bool bMultipleRows = false, bMultipleCols = false;
for( size_t nRangeIdx = 0; nRangeIdx < nRangeCount; ++nRangeIdx )
{
const ScRange rRange = aRangeList[ nRangeIdx ];
const ScRange & rRange = aRangeList[ nRangeIdx ];
bMultipleRows = ( bMultipleRows || ( rRange.aStart.Row() != rRange.aEnd.Row() ) );
bMultipleCols = ( bMultipleCols || ( rRange.aStart.Col() != rRange.aEnd.Col() ) );
SCTAB nMax = static_cast<SCTAB>(maTabs.size());
......
......@@ -76,18 +76,6 @@ private:
const T& mrTest;
};
class AppendToList
{
public:
explicit AppendToList(vector<ScRange>& rRanges) : mrRanges(rRanges) {}
void operator() (const ScRange& r)
{
mrRanges.push_back(r);
}
private:
vector<ScRange>& mrRanges;
};
class CountCells
{
public:
......@@ -143,7 +131,6 @@ private:
// ScRangeList
ScRangeList::~ScRangeList()
{
RemoveAll();
}
ScRefFlags ScRangeList::Parse( const OUString& rStr, const ScDocument* pDoc,
......@@ -1034,11 +1021,9 @@ ScRangeList::ScRangeList() : mnMaxRowUsed(-1) {}
ScRangeList::ScRangeList( const ScRangeList& rList ) :
SvRefBase(),
mnMaxRowUsed(-1)
maRanges(rList.maRanges),
mnMaxRowUsed(rList.mnMaxRowUsed)
{
maRanges.reserve(rList.maRanges.size());
for_each(rList.maRanges.begin(), rList.maRanges.end(), AppendToList(maRanges));
mnMaxRowUsed = rList.mnMaxRowUsed;
}
ScRangeList::ScRangeList( const ScRangeList&& rList ) :
......@@ -1057,9 +1042,7 @@ ScRangeList::ScRangeList( const ScRange& rRange ) :
ScRangeList& ScRangeList::operator=(const ScRangeList& rList)
{
RemoveAll();
maRanges.reserve(rList.maRanges.size());
for_each(rList.maRanges.begin(), rList.maRanges.end(), AppendToList(maRanges));
maRanges = rList.maRanges;
mnMaxRowUsed = rList.mnMaxRowUsed;
return *this;
}
......@@ -1098,6 +1081,7 @@ void ScRangeList::Remove(size_t nPos)
void ScRangeList::RemoveAll()
{
maRanges.clear();
mnMaxRowUsed = -1;
}
ScRange ScRangeList::Combine() const
......
......@@ -511,14 +511,13 @@ static void lcl_collectAllPredOrSuccRanges(
{
ScDocument& rDoc = rDocShell.GetDocument();
vector<ScTokenRef> aRefTokens;
ScRangeList aSrcRanges(rSrcRanges);
if (aSrcRanges.empty())
if (rSrcRanges.empty())
return;
ScRange const & rFrontRange = aSrcRanges.front();
ScRange const & rFrontRange = rSrcRanges.front();
ScDetectiveFunc aDetFunc(&rDoc, rFrontRange.aStart.Tab());
for (size_t i = 0, n = aSrcRanges.size(); i < n; ++i)
for (size_t i = 0, n = rSrcRanges.size(); i < n; ++i)
{
ScRange const & r = aSrcRanges[i];
ScRange const & r = rSrcRanges[i];
if (bPred)
{
aDetFunc.GetAllPreds(
......
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