From c2e28f50354d4e95b2202aebe1764d81fdbfd27e Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 17 May 2013 22:45:43 -0400 Subject: Prefer early bail-out. Change-Id: I112a4be56910c07007b28715336fcd82d56bb313 --- sc/source/core/data/column3.cxx | 73 +++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'sc/source') diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index f5730118d1e2..70d007dca056 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -1103,38 +1103,40 @@ ScAttrIterator* ScColumn::CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) c void ScColumn::StartAllListeners() { - if ( !maItems.empty() ) - for (SCSIZE i = 0; i < maItems.size(); i++) + if (maItems.empty()) + return; + + for (SCSIZE i = 0; i < maItems.size(); i++) + { + ScBaseCell* pCell = maItems[i].pCell; + if ( pCell->GetCellType() == CELLTYPE_FORMULA ) { - ScBaseCell* pCell = maItems[i].pCell; - if ( pCell->GetCellType() == CELLTYPE_FORMULA ) - { - SCROW nRow = maItems[i].nRow; - ((ScFormulaCell*)pCell)->StartListeningTo( pDocument ); - if ( nRow != maItems[i].nRow ) - Search( nRow, i ); // Insert Listener? - } + SCROW nRow = maItems[i].nRow; + ((ScFormulaCell*)pCell)->StartListeningTo( pDocument ); + if ( nRow != maItems[i].nRow ) + Search( nRow, i ); // Insert Listener? } + } } void ScColumn::StartNeededListeners() { - if ( !maItems.empty() ) + if (maItems.empty()) + return; + + for (SCSIZE i = 0; i < maItems.size(); i++) { - for (SCSIZE i = 0; i < maItems.size(); i++) + ScBaseCell* pCell = maItems[i].pCell; + if ( pCell->GetCellType() == CELLTYPE_FORMULA ) { - ScBaseCell* pCell = maItems[i].pCell; - if ( pCell->GetCellType() == CELLTYPE_FORMULA ) + ScFormulaCell* pFCell = static_cast(pCell); + if (pFCell->NeedsListening()) { - ScFormulaCell* pFCell = static_cast(pCell); - if (pFCell->NeedsListening()) - { - SCROW nRow = maItems[i].nRow; - pFCell->StartListeningTo( pDocument ); - if ( nRow != maItems[i].nRow ) - Search( nRow, i ); // Insert Listener? - } + SCROW nRow = maItems[i].nRow; + pFCell->StartListeningTo( pDocument ); + if ( nRow != maItems[i].nRow ) + Search( nRow, i ); // Insert Listener? } } } @@ -1166,20 +1168,21 @@ void ScColumn::BroadcastInArea( SCROW nRow1, SCROW nRow2 ) void ScColumn::StartListeningInArea( SCROW nRow1, SCROW nRow2 ) { - if ( !maItems.empty() ) + if (maItems.empty()) + return; + + SCROW nRow; + SCSIZE nIndex; + Search( nRow1, nIndex ); + while ( nIndex < maItems.size() && (nRow = maItems[nIndex].nRow) <= nRow2 ) { - SCROW nRow; - SCSIZE nIndex; - Search( nRow1, nIndex ); - while ( nIndex < maItems.size() && (nRow = maItems[nIndex].nRow) <= nRow2 ) - { - ScBaseCell* pCell = maItems[nIndex].pCell; - if ( pCell->GetCellType() == CELLTYPE_FORMULA ) - ((ScFormulaCell*)pCell)->StartListeningTo( pDocument ); - if ( nRow != maItems[nIndex].nRow ) - Search( nRow, nIndex ); // Inserted via Listening - nIndex++; - } + ScBaseCell* pCell = maItems[nIndex].pCell; + if ( pCell->GetCellType() == CELLTYPE_FORMULA ) + ((ScFormulaCell*)pCell)->StartListeningTo( pDocument ); + if ( nRow != maItems[nIndex].nRow ) + Search( nRow, nIndex ); // Inserted via Listening + + ++nIndex; } } -- cgit