summaryrefslogtreecommitdiff
path: root/sc/source/core/data/table1.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-08-22 11:43:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-08-25 15:27:58 +0200
commitc47eb8afd1b941a4dca832cfad85ba750c76635d (patch)
tree283e513b21840c9e8c5b82f9b71a5fcd0f143b21 /sc/source/core/data/table1.cxx
parent27bde9a6abf6c73d5345b0a85b81afc8470d25cf (diff)
dynamic column container: more efficient loops over all cols
Create an ScColumnsRange class that returns a pair of (start,end) iterators to go through the list of currently allocated columns. This is a fairly thing wrapper around the underlying std::vector, so it should be fairly efficient (two pointers, and pointer increment for iteration). If this style of iteration is acceptable, I'll go through the rest of the code that does: for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++) type stuff, and change it to use ScColumnsRange. Change-Id: I81501c69b7f5566c6204dde0d87a6fe0deb9743c Reviewed-on: https://gerrit.libreoffice.org/41413 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/core/data/table1.cxx')
-rw-r--r--sc/source/core/data/table1.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index ad1a50ee3828..c10100d4777b 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1681,14 +1681,14 @@ void ScTable::UpdateReference(
void ScTable::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
ScDocument* pUndoDoc )
{
- for ( SCCOL i=0; i<=MAXCOL; i++ )
- aCol[i].UpdateTranspose( rSource, rDest, pUndoDoc );
+ for (ScColumn* pCol : GetColumnsRange(0, MAXCOL))
+ pCol->UpdateTranspose( rSource, rDest, pUndoDoc );
}
void ScTable::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
{
- for ( SCCOL i=0; i<=MAXCOL; i++ )
- aCol[i].UpdateGrow( rArea, nGrowX, nGrowY );
+ for (ScColumn* pCol : GetColumnsRange(0, MAXCOL))
+ pCol->UpdateGrow( rArea, nGrowX, nGrowY );
}
void ScTable::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt )
@@ -2383,4 +2383,10 @@ const ScConditionalFormatList* ScTable::GetCondFormList() const
return mpCondFormatList.get();
}
+ScColumnsRange ScTable::GetColumnsRange(SCCOL nColBegin, SCCOL nColEnd) const
+{
+ // because the range is inclusive, some code will pass nColEnd<nColBegin to indicate an empty range
+ return ScColumnsRange(aCol.begin() + nColBegin, nColEnd < nColBegin ? (aCol.begin() + nColBegin) : (aCol.begin() + nColEnd + 1));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */