svl/source/items/itemset.cxx |   29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

New commits:
commit 1cfa3f8694d4b585549e6dae7396d408184106cb
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat May 28 17:05:03 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat May 28 19:31:20 2022 +0200

    simplify SfxItemSet::Differentiate and SfxItemSet::Intersect
    
    using SfxWhichIter instead of SfxItemIter
    
    Change-Id: I046ae2cec9246b1dea9c484f94b88d64825f952c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135077
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 842bc2d16623..e0e1ee8823a3 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -887,17 +887,14 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet )
     }
     else
     {
-        SfxItemIter aIter( *this );
-        const SfxPoolItem* pItem = aIter.GetCurItem();
-        do
+        SfxWhichIter aIter( *this );
+        sal_uInt16 nWhich = aIter.FirstWhich();
+        while ( nWhich )
         {
-            sal_uInt16 nWhich = IsInvalidItem( pItem )
-                                ? GetWhichByPos( aIter.GetCurPos() )
-                                : pItem->Which();
             if( SfxItemState::UNKNOWN == rSet.GetItemState( nWhich, false ) )
-                ClearItem( nWhich );        // Delete
-            pItem = aIter.NextItem();
-        } while (pItem);
+                ClearItem( nWhich ); // Delete
+            nWhich = aIter.NextWhich();
+        }
     }
 }
 
@@ -936,18 +933,14 @@ void SfxItemSet::Differentiate( const SfxItemSet& rSet )
     }
     else
     {
-        SfxItemIter aIter( *this );
-        const SfxPoolItem* pItem = aIter.GetCurItem();
-        do
+        SfxWhichIter aIter( *this );
+        sal_uInt16 nWhich = aIter.FirstWhich();
+        while ( nWhich )
         {
-            sal_uInt16 nWhich = IsInvalidItem( pItem )
-                                ? GetWhichByPos( aIter.GetCurPos() )
-                                : pItem->Which();
             if( SfxItemState::SET == rSet.GetItemState( nWhich, false ) )
                 ClearItem( nWhich ); // Delete
-            pItem = aIter.NextItem();
-        } while (pItem);
-
+            nWhich = aIter.NextWhich();
+        }
     }
 }
 

Reply via email to