[Libreoffice-commits] core.git: sc/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu May 24 07:48:29 UTC 2018
sc/source/core/data/document.cxx | 2 +-
sc/source/core/tool/rangelst.cxx | 24 ++++--------------------
sc/source/ui/docshell/docfunc.cxx | 9 ++++-----
3 files changed, 9 insertions(+), 26 deletions(-)
New commits:
commit 95e6c264e69e71d84e5a02ad7ab87ff944cfb17a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed May 23 15:03:27 2018 +0200
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 at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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(
More information about the Libreoffice-commits
mailing list