summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-11-04 14:20:23 +0100
committerEike Rathke <erack@redhat.com>2016-11-04 14:20:54 +0100
commit2ba62a78151c3cd8a104b763f29432bb49de5e26 (patch)
tree10c4d51868cedc0093e408ba7a4676f004048057
parentc1805c48ae6057d370a35f2e059f3ee82396c407 (diff)
sc-perf: eliminate unnecessary loops in ScTable::UpdateSelectionFunction()
That looped unconditionally over all columns of a sheet just to let ScColumn::UpdateSelectionFunction() costly (by creating empty spans) decide that it doesn't have to do anything. This for *every* cell cursor movement or switching sheets et al. Instead, use the ScMarkData area to narrow down the range beforehand, which when travelling with the cell cursor is just one column. Change-Id: Ic60928d07bc6cec4f6d8491ab30b99d7b20b8490
-rw-r--r--sc/source/core/data/table3.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 311ac02182ad..1336e041b81e 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -3404,7 +3404,20 @@ sal_Int32 ScTable::GetMaxNumberStringLen(
void ScTable::UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark )
{
ScRangeList aRanges = rMark.GetMarkedRangesForTab( nTab );
- for (SCCOL nCol = 0; nCol <= MAXCOL && !rData.bError; ++nCol)
+ ScRange aMarkArea( ScAddress::UNINITIALIZED );
+ if (rMark.IsMultiMarked())
+ rMark.GetMultiMarkArea( aMarkArea );
+ else if (rMark.IsMarked())
+ rMark.GetMarkArea( aMarkArea );
+ else
+ {
+ assert(!"ScTable::UpdateSelectionFunction - called without anything marked");
+ aMarkArea.aStart.SetCol(0);
+ aMarkArea.aEnd.SetCol(MAXCOL);
+ }
+ const SCCOL nStartCol = aMarkArea.aStart.Col();
+ const SCCOL nEndCol = aMarkArea.aEnd.Col();
+ for (SCCOL nCol = nStartCol; nCol <= nEndCol && !rData.bError; ++nCol)
{
if (pColFlags && ColHidden(nCol))
continue;