simplify CreateColumnIfNotExists

if "if (aOldColSize==0)" check can never be hit since we pre-allocate
these columns to some size.

Also move the cold part of the function out-of-line, doesn't seem useful
to have all of it in a header

Change-Id: If8675ca17d70ee55dde8418ff75e2ddb3c931c58
Reviewed-on: https://gerrit.libreoffice.org/68506
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2019-02-28 14:45:17 +02:00
parent 205e2d6c31
commit f9845d1a2d
2 changed files with 11 additions and 10 deletions

View File

@@ -276,18 +276,11 @@ public:
ScColumn& CreateColumnIfNotExists( const SCCOL nScCol )
{
if ( nScCol >= aCol.size() )
{
const SCCOL aOldColSize = aCol.size();
bool bUseEmptyAttrArray = false;
if ( aOldColSize == 0 )
bUseEmptyAttrArray = true;
aCol.resize( static_cast< size_t >( nScCol + 1 ) );
for (SCCOL i = aOldColSize; i <= nScCol; i++)
aCol[i].Init( i, nTab, pDocument, bUseEmptyAttrArray );
}
CreateColumnIfNotExistsImpl(nScCol);
return aCol[nScCol];
}
// out-of-line the cold part of the function
void CreateColumnIfNotExistsImpl( const SCCOL nScCol );
sal_uLong GetCellCount() const;
sal_uLong GetWeightedCount() const;
sal_uLong GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;

View File

@@ -2533,4 +2533,12 @@ ScColumnsRange ScTable::GetColumnsRange(SCCOL nColBegin, SCCOL nColEnd) const
ScColumnsRange::Iterator( aCol.begin() + nEffEnd));
}
// out-of-line the cold part of the CreateColumnIfNotExists function
void ScTable::CreateColumnIfNotExistsImpl( const SCCOL nScCol )
{
const SCCOL aOldColSize = aCol.size();
aCol.resize( static_cast< size_t >( nScCol + 1 ) );
for (SCCOL i = aOldColSize; i <= nScCol; i++)
aCol[i].Init( i, nTab, pDocument, false );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */