diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-09-30 20:22:30 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-10-01 06:33:11 +0200 |
commit | 1fc63383ccd8af144d681ba405f5ead863ac24e1 (patch) | |
tree | 77d41033131babef8db1dd7ffb6e00b0f0ac3237 /sw/source/filter/ww8 | |
parent | 4814e8caa5f06c4fe438dfd7d7315e4a2410ea18 (diff) |
Avoid redundant IsAtEnd: NextItem returns nullptr iif iterator is at end
To keep the check efficient, split NextItem to inline and Impl parts
Change-Id: Id5877a3c5bed73aac9c39c655b106a715cf888ea
Reviewed-on: https://gerrit.libreoffice.org/79894
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r-- | sw/source/filter/ww8/writerhelper.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8gr.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par3.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 2 |
7 files changed, 20 insertions, 29 deletions
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 4c45fc48abb9..520283dc5fe1 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -410,7 +410,7 @@ namespace sw { do rItems[pItem->Which()] = pItem; - while (!aIter.IsAtEnd() && nullptr != (pItem = aIter.NextItem())); + while ((pItem = aIter.NextItem())); } } } @@ -434,7 +434,7 @@ namespace sw const SfxPoolItem *pItem = aIter.GetCurItem(); do rSet.ClearItem(pItem->Which()); - while (!aIter.IsAtEnd() && nullptr != (pItem = aIter.NextItem())); + while ((pItem = aIter.NextItem())); } } } diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 3d38d9ced1e8..7932a848cc4a 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1319,7 +1319,7 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>* if (m_rExport.CollapseScriptsforWordOk(nScript,nWhich)) m_rExport.AttrOutput().OutputItem(*pI); } - } while( !aIter.IsAtEnd() && nullptr != ( pItem = aIter.NextItem() ) ); + } while ((pItem = aIter.NextItem())); m_rExport.SetCurItemSet( pOldSet ); } } diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index 61d9ad960a27..d66cb8cc280f 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -99,9 +99,8 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStora { bool bGraphicNeeded = false; SfxItemIter aIter( rSet ); - const SfxPoolItem* pItem = aIter.GetCurItem(); - - do { + for (auto pItem = aIter.GetCurItem(); !bGraphicNeeded && pItem; pItem = aIter.NextItem()) + { switch (pItem->Which()) { /* @@ -121,8 +120,7 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStora default: bGraphicNeeded = true; } - } while( !bGraphicNeeded && !aIter.IsAtEnd() && - nullptr != ( pItem = aIter.NextItem() ) ); + } /* Now we must see if the object contains a preview itself which is equal to diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 535a6568360c..73059165f100 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -5429,12 +5429,12 @@ void AttributeOutputBase::OutputStyleItemSet( const SfxItemSet& rSet, bool bTest const SfxPoolItem* pItem; if ( !pSet->GetParent() ) { - OSL_ENSURE( rSet.Count(), "Was already handled or?" ); + assert(rSet.Count() && "Was already handled or?"); SfxItemIter aIter( *pSet ); pItem = aIter.GetCurItem(); do { OutputItem( *pItem ); - } while ( !aIter.IsAtEnd() && nullptr != ( pItem = aIter.NextItem() ) ); + } while ((pItem = aIter.NextItem())); } else { diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 0c2808864dab..a525b2a996d0 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -2876,17 +2876,12 @@ void SwWW8ImplReader::PostProcessAttrs() { SfxItemIter aIter(m_pPostProcessAttrsInfo->mItemSet); - const SfxPoolItem * pItem = aIter.GetCurItem(); - if (pItem != nullptr) + for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem()) { - do - { - m_xCtrlStck->NewAttr(*m_pPostProcessAttrsInfo->mPaM.GetPoint(), - *pItem); - m_xCtrlStck->SetAttr(*m_pPostProcessAttrsInfo->mPaM.GetMark(), - pItem->Which()); - } - while (!aIter.IsAtEnd() && nullptr != (pItem = aIter.NextItem())); + m_xCtrlStck->NewAttr(*m_pPostProcessAttrsInfo->mPaM.GetPoint(), + *pItem); + m_xCtrlStck->SetAttr(*m_pPostProcessAttrsInfo->mPaM.GetMark(), + pItem->Which()); } m_pPostProcessAttrsInfo.reset(); diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 1fd69d154894..3b5deed3e5ff 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -1017,24 +1017,22 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, SwNumRule& rNumRule, && (pLowerLevelItemSet->Count() == pThisLevelItemSet->Count()) ) { nIdenticalItemSetLevel = nLowerLevel; - sal_uInt16 nWhich = aIter.GetCurItem()->Which(); - while (true) + const SfxPoolItem* pItemIter = aIter.GetCurItem(); + do { if( // search for appropriate pItem in pLowerLevelItemSet (SfxItemState::SET != pLowerLevelItemSet->GetItemState( - nWhich, false, &pItem ) ) + pItemIter->Which(), false, &pItem ) ) || // use virtual "!=" Operator - (*pItem != *aIter.GetCurItem() ) ) + (*pItem != *pItemIter) ) // if no Item with equal nWhich was found or Item value was not equal // store inequality and break! { nIdenticalItemSetLevel = nMaxLevel; break; } - if( aIter.IsAtEnd() ) - break; - nWhich = aIter.NextItem()->Which(); - } + pItemIter = aIter.NextItem(); + } while (pItemIter); if( nIdenticalItemSetLevel != nMaxLevel ) break; diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index aa68d9180295..2e21260408df 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2265,7 +2265,7 @@ void WW8DupProperties::Insert(const SwPosition &rPos) do { pCtrlStck->NewAttr(rPos, *pItem); - }while( !aIter.IsAtEnd() && nullptr != ( pItem = aIter.NextItem() ) ); + } while ((pItem = aIter.NextItem())); } } } |