summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-05-23 15:03:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-05-24 09:48:08 +0200
commit95e6c264e69e71d84e5a02ad7ab87ff944cfb17a (patch)
treec608e643aae76703ecaffd27ae3b6b0c15504014
parent2a93d2a4af7bb72b155f91e18239cc1b5bc90a4e (diff)
reduce some unnecessary ScRangeList copying
and reduce unnecessary work in ScRangeList Change-Id: I0ee767fe28571f75f8a2ff980cea27c97c9797dc Reviewed-on: https://gerrit.libreoffice.org/54705 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/core/data/document.cxx2
-rw-r--r--sc/source/core/tool/rangelst.cxx24
-rw-r--r--sc/source/ui/docshell/docfunc.cxx9
3 files changed, 9 insertions, 26 deletions
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f57c7d984559..2014f09b9e71 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -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());
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 5380a7aa321d..51693615e653 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -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
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 2e122db92332..3908a1a35279 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -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(