summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-09-30 20:22:30 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-10-01 06:33:11 +0200
commit1fc63383ccd8af144d681ba405f5ead863ac24e1 (patch)
tree77d41033131babef8db1dd7ffb6e00b0f0ac3237 /svl
parent4814e8caa5f06c4fe438dfd7d7315e4a2410ea18 (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 'svl')
-rw-r--r--svl/source/items/itemiter.cxx17
-rw-r--r--svl/source/items/itemset.cxx12
2 files changed, 11 insertions, 18 deletions
diff --git a/svl/source/items/itemiter.cxx b/svl/source/items/itemiter.cxx
index aaedcf26ae33..fe0ee377f439 100644
--- a/svl/source/items/itemiter.cxx
+++ b/svl/source/items/itemiter.cxx
@@ -50,17 +50,14 @@ SfxItemIter::~SfxItemIter()
{
}
-const SfxPoolItem* SfxItemIter::NextItem()
+// Precondition : m_nCurrent < m_nEnd
+const SfxPoolItem* SfxItemIter::ImplNextItem()
{
- if (m_nCurrent < m_nEnd)
- {
- SfxPoolItem const** ppFnd = m_rSet.m_pItems.get();
- do {
- m_nCurrent++;
- } while (m_nCurrent < m_nEnd && !*(ppFnd + m_nCurrent ));
- return *(ppFnd+m_nCurrent);
- }
- return nullptr;
+ SfxPoolItem const** ppFnd = m_rSet.m_pItems.get();
+ do {
+ m_nCurrent++;
+ } while (m_nCurrent < m_nEnd && !*(ppFnd + m_nCurrent ));
+ return *(ppFnd+m_nCurrent);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 35da205612ac..f325cec50f34 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1014,17 +1014,15 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet )
{
SfxItemIter aIter( *this );
const SfxPoolItem* pItem = aIter.GetCurItem();
- while( true )
+ do
{
sal_uInt16 nWhich = IsInvalidItem( pItem )
? GetWhichByPos( aIter.GetCurPos() )
: pItem->Which();
if( SfxItemState::UNKNOWN == rSet.GetItemState( nWhich, false ) )
ClearItem( nWhich ); // Delete
- if( aIter.IsAtEnd() )
- break;
pItem = aIter.NextItem();
- }
+ } while (pItem);
}
}
@@ -1080,17 +1078,15 @@ void SfxItemSet::Differentiate( const SfxItemSet& rSet )
{
SfxItemIter aIter( *this );
const SfxPoolItem* pItem = aIter.GetCurItem();
- while( true )
+ do
{
sal_uInt16 nWhich = IsInvalidItem( pItem )
? GetWhichByPos( aIter.GetCurPos() )
: pItem->Which();
if( SfxItemState::SET == rSet.GetItemState( nWhich, false ) )
ClearItem( nWhich ); // Delete
- if( aIter.IsAtEnd() )
- break;
pItem = aIter.NextItem();
- }
+ } while (pItem);
}
}