[Libreoffice-commits] core.git: include/svl sd/source svl/source
Jochen Nitschke
j.nitschke+logerrit at ok.de
Sat Feb 4 11:38:24 UTC 2017
include/svl/whiter.hxx | 10 +++++-----
sd/source/ui/view/drviewsf.cxx | 5 +++--
svl/source/items/whiter.cxx | 39 ++++++++++++++-------------------------
3 files changed, 22 insertions(+), 32 deletions(-)
New commits:
commit d584e2dcc0454e66151d888fb45c23ccb1634aa6
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date: Sat Feb 4 11:44:27 2017 +0100
simplify SfxWhichIter
only one of 164 calls used the ctor with a restricting range.
handle this special case.
remove nFrom and nTo members.
use operator[] on range pointer to highlight we access lower [0]
and upper [1] range bound.
remove dtor.
Change-Id: I87b28502515e45bb190425eb88aa187ac0b5b2d2
Reviewed-on: https://gerrit.libreoffice.org/33911
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>
diff --git a/include/svl/whiter.hxx b/include/svl/whiter.hxx
index e23633e..a6473d8 100644
--- a/include/svl/whiter.hxx
+++ b/include/svl/whiter.hxx
@@ -26,14 +26,14 @@ class SfxItemSet;
class SVL_DLLPUBLIC SfxWhichIter
{
- const sal_uInt16 *pRanges, *pStart;
- sal_uInt16 nOfst, nFrom, nTo;
+ const sal_uInt16* const pStart;
+ const sal_uInt16* pRanges;
+ sal_uInt16 nOffset;
public:
- SfxWhichIter( const SfxItemSet& rSet, sal_uInt16 nFrom = 0, sal_uInt16 nTo = USHRT_MAX );
- ~SfxWhichIter();
+ SfxWhichIter( const SfxItemSet& rSet );
- sal_uInt16 GetCurWhich() const { return *pRanges + nOfst; }
+ sal_uInt16 GetCurWhich() const { return pRanges[0] + nOffset; }
sal_uInt16 NextWhich();
sal_uInt16 FirstWhich();
};
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index e6fe654..0a7c7e0 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -690,11 +690,12 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
// changed from SfxItemState::DEFAULT (_ON) to SfxItemState::DISABLED
if( mpDrawView->AreObjectsMarked() )
{
- SfxWhichIter aNewIter( *pSet, XATTR_LINE_FIRST, XATTR_FILL_LAST );
+ SfxWhichIter aNewIter( *pSet );
nWhich = aNewIter.FirstWhich();
while( nWhich )
{
- if( SfxItemState::DEFAULT == pSet->GetItemState( nWhich ) )
+ if (nWhich >= XATTR_LINE_FIRST && nWhich <= XATTR_LINE_LAST
+ && SfxItemState::DEFAULT == pSet->GetItemState(nWhich) )
{
rSet.ClearItem( nWhich );
rSet.DisableItem( nWhich );
diff --git a/svl/source/items/whiter.cxx b/svl/source/items/whiter.cxx
index d69960c..88b487b 100644
--- a/svl/source/items/whiter.cxx
+++ b/svl/source/items/whiter.cxx
@@ -21,44 +21,33 @@
#include <svl/whiter.hxx>
#include <svl/itemset.hxx>
-SfxWhichIter::SfxWhichIter( const SfxItemSet& rSet, sal_uInt16 nFromWh, sal_uInt16 nToWh ):
- pRanges(rSet.GetRanges()),
+SfxWhichIter::SfxWhichIter( const SfxItemSet& rSet ):
pStart(rSet.GetRanges()),
- nOfst(0), nFrom(nFromWh), nTo(nToWh)
-{
- if (nFrom > 0)
- (void)FirstWhich();
-}
-
-SfxWhichIter::~SfxWhichIter()
+ pRanges(pStart),
+ nOffset(0)
{
}
sal_uInt16 SfxWhichIter::NextWhich()
{
- while ( 0 != *pRanges )
+ if ( 0 == pRanges[0] )
+ return 0;
+
+ const sal_uInt16 nLastWhich = pRanges[0] + nOffset;
+ ++nOffset;
+ if (pRanges[1] == nLastWhich)
{
- const sal_uInt16 nLastWhich = *pRanges + nOfst;
- ++nOfst;
- if (*(pRanges+1) == nLastWhich)
- {
- pRanges += 2;
- nOfst = 0;
- }
- sal_uInt16 nWhich = *pRanges + nOfst;
- if ( 0 == nWhich || ( nWhich >= nFrom && nWhich <= nTo ) )
- return nWhich;
+ pRanges += 2;
+ nOffset = 0;
}
- return 0;
+ return pRanges[0] + nOffset;
}
sal_uInt16 SfxWhichIter::FirstWhich()
{
pRanges = pStart;
- nOfst = 0;
- if ( *pRanges >= nFrom && *pRanges <= nTo )
- return *pRanges;
- return NextWhich();
+ nOffset = 0;
+ return pRanges[0];
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list