diff options
author | Noel Grandin <noel@peralex.com> | 2016-02-02 16:15:51 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-02-08 06:08:14 +0000 |
commit | b14224fe97b8a44232c9c1401d3a49771f46582e (patch) | |
tree | 8f9cf31cf4b51a0edbb43022499a6acd17d0945d /svl | |
parent | c474e610e453d0f38f7cc6cb9559ad7e7b5d69ca (diff) |
loplugin:unusedmethods
using an idea from dtardon:
<dtardon> noelgrandin, hi. could you try to run the unusedmethods clang
plugin with "make build-nocheck"? that would catch functions that are
only used in tests. e.g., i just removed the whole o3tl::range class,
which has not been used in many years, but htere was a test for it...
<noelgrandin> dtardon, interesting idea! Sure, I can do that.
Change-Id: I5653953a426a2186a1e43017212d87ffce520387
Reviewed-on: https://gerrit.libreoffice.org/22041
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/nranges.cxx | 278 |
1 files changed, 0 insertions, 278 deletions
diff --git a/svl/source/items/nranges.cxx b/svl/source/items/nranges.cxx index 7bd5c8895153..da3e21768358 100644 --- a/svl/source/items/nranges.cxx +++ b/svl/source/items/nranges.cxx @@ -170,35 +170,6 @@ SfxUShortRanges::SfxUShortRanges( const sal_uInt16* pArr ) } -bool SfxUShortRanges::operator==( const SfxUShortRanges &rOther ) const -{ - // Object pointers equal? - if ( this == &rOther ) - return true; - - // Ranges pointers equal? - if ( _pRanges == rOther._pRanges ) - return true; - - // Counts equal? - sal_uInt16 nCount = Count(); - if ( nCount != rOther.Count() ) - return false; - - // Check arrays. - sal_uInt16 n = 0; - while( _pRanges[ n ] != 0 ) - { - // Elements at current position equal? - if ( _pRanges[ n ] != rOther._pRanges[ n ] ) - return false; - - ++n; - } - - return true; -} - /** * Assigns ranges from 'rRanges' to '*this'. */ @@ -381,255 +352,6 @@ copy_rest: } /** - * Removes 'rRanges' from '*this'. - * for each sal_uInt16 n: - * this->Contains( n ) && rRanges.Contains( n ) => !this'->Contains( n ) - * this->Contains( n ) && !rRanges.Contains( n ) => this'->Contains( n ) - * !this->Contains( n ) => !this'->Contains( n ) - */ -SfxUShortRanges& SfxUShortRanges::operator -= -( - const SfxUShortRanges &rRanges -) -{ - // special cases: one is empty - if ( rRanges.IsEmpty() || IsEmpty() ) - return *this; - - // differentiate 'rRanges' in a temporary copy of '*this' - // (size is computed for maximal possibly split-count plus terminating 0) - sal_uInt16 nThisSize = Count_Impl(_pRanges); - sal_uInt16 nTargetSize = 1 + ( nThisSize + Count_Impl(rRanges._pRanges) ); - std::unique_ptr<sal_uInt16[]> pTarget(new sal_uInt16[ nTargetSize ]); - memset( pTarget.get(), 0, sizeof(sal_uInt16)*nTargetSize ); - memcpy( pTarget.get(), _pRanges, sizeof(sal_uInt16)*nThisSize ); - - sal_uInt16 nPos1 = 0, nPos2 = 0, nTargetPos = 0; - while( _pRanges[ nPos1 ] ) - { - sal_uInt16 l1 = _pRanges[ nPos1 ]; // lower bound of interval 1 - sal_uInt16 u1 = _pRanges[ nPos1+1 ]; // upper bound of interval 1 - sal_uInt16 l2 = rRanges._pRanges[ nPos2 ]; // lower bound of interval 2 - sal_uInt16 u2 = rRanges._pRanges[ nPos2+1 ]; // upper bound of interval 2 - - // boundary cases - // * subtrahend is empty -> copy the minuend - if( !l2 ) - { - pTarget[ nTargetPos ] = l1; - pTarget[ nTargetPos+1 ] = u1; - nTargetPos += 2; - nPos1 += 2; - continue; - } - // * next subtrahend interval is completely higher -> copy the minuend - if( u1 < l2 ) - { - pTarget[ nTargetPos ] = l1; - pTarget[ nTargetPos+1 ] = u1; - nTargetPos += 2; - nPos1 += 2; - continue; - } - - // * next subtrahend interval is completely lower -> try next - if( u2 < l1 ) - { - nPos2 += 2; - continue; - } - - // intersecting cases - // * subtrahend cuts out from the beginning of the minuend - if( l2 <= l1 && u2 <= u1 ) - { - // reduce minuend interval, try again (minuend might be affected by other subtrahend intervals) - _pRanges[ nPos1 ] = u2 + 1; - nPos2 += 2; // this cannot hurt any longer - continue; - } - - // * subtrahend cuts out from the end of the minuend - if( l1 <= l2 && u1 <= u2 ) - { - // copy remaining part of minuend (cannot be affected by other intervals) - if( l1 < l2 ) // anything left at all? - { - pTarget[ nTargetPos ] = l1; - pTarget[ nTargetPos+1 ] = l2 - 1; - nTargetPos += 2; - // do not increment nPos2, might affect next minuend interval, too - } - nPos1 += 2; // nothing left at all - continue; - } - - // * subtrahend completely deletes minuend (larger or same at both ends) - if( l1 >= l2 && u1 <= u2 ) - { - nPos1 += 2; // minuend deleted - // do not increment nPos2, might affect next minuend interval, too - continue; - } - - // * subtrahend divides minuend into two pieces - if( l1 <= l2 && u1 >= u2 ) // >= and <= since they may be something left only at one side - { - // left side - if( l1 < l2 ) // anything left at all - { - pTarget[ nTargetPos ] = l1; - pTarget[ nTargetPos+1 ] = l2 - 1; - nTargetPos += 2; - } - - // right side - if( u1 > u2 ) // anything left at all - { - // reduce minuend interval, try again (minuend might be affected by other subtrahend intervals ) - _pRanges[ nPos1 ] = u2 + 1; - } - - // subtrahend is completely used - nPos2 += 2; - continue; - } - - // we should never be here - OSL_FAIL( "SfxUShortRanges::operator-=: internal error" ); - } // while - - pTarget[ nTargetPos ] = 0; - - // assign the differentiated ranges - delete[] _pRanges; - - sal_uInt16 nUShorts = Count_Impl(pTarget.get()) + 1; - if ( 1 != nUShorts ) - { - _pRanges = new sal_uInt16[ nUShorts ]; - memcpy( _pRanges, pTarget.get(), nUShorts * sizeof(sal_uInt16) ); - } - else - _pRanges = nullptr; - - return *this; -} - -/** - * Determines intersection of '*this' with 'rRanges'. - * for each sal_uInt16 n: - * this->Contains( n ) && rRanges.Contains( n ) => this'->Contains( n ) - * !this->Contains( n ) => !this'->Contains( n ) - * !rRanges.Contains( n ) => !this'->Contains( n ) - */ -SfxUShortRanges& SfxUShortRanges::operator /= -( - const SfxUShortRanges &rRanges -) -{ - // boundary cases - // * first set is empty -> nothing to be done - // * second set is empty -> delete first set - if( rRanges.IsEmpty() ) - { - delete[] _pRanges; - - _pRanges = new sal_uInt16[1]; - _pRanges[0] = 0; - - return *this; - } - - // intersect 'rRanges' in a temporary copy of '*this' - // (size is computed for maximal possibly split-count plus terminating 0) - sal_uInt16 nThisSize = Count_Impl(_pRanges); - sal_uInt16 nTargetSize = 1 + ( nThisSize + Count_Impl(rRanges._pRanges) ); - std::unique_ptr<sal_uInt16[]> pTarget(new sal_uInt16[ nTargetSize ]); - memset( pTarget.get(), 0, sizeof(sal_uInt16)*nTargetSize ); - memcpy( pTarget.get(), _pRanges, sizeof(sal_uInt16)*nThisSize ); - - sal_uInt16 nPos1 = 0, nPos2 = 0, nTargetPos = 0; - while( _pRanges[ nPos1 ] != 0 && rRanges._pRanges[ nPos2 ] != 0 ) - { - sal_uInt16 l1 = _pRanges[ nPos1 ]; // lower bound of interval 1 - sal_uInt16 u1 = _pRanges[ nPos1+1 ]; // upper bound of interval 1 - sal_uInt16 l2 = rRanges._pRanges[ nPos2 ]; // lower bound of interval 2 - sal_uInt16 u2 = rRanges._pRanges[ nPos2+1 ]; // upper bound of interval 2 - - if( u1 < l2 ) - { - // current interval in s1 is completely before ci in s2 - nPos1 += 2; - continue; - } - if( u2 < l1 ) - { - // ci in s2 is completely before ci in s1 - nPos2 += 2; - continue; - } - - // assert: there exists an intersection between ci1 and ci2 - - if( l1 <= l2 ) - { - // c1 "is more to the left" than c2 - - if( u1 <= u2 ) - { - pTarget[ nTargetPos ] = l2; - pTarget[ nTargetPos+1 ] = u1; - nTargetPos += 2; - nPos1 += 2; - continue; - } - else - { - pTarget[ nTargetPos ] = l2; - pTarget[ nTargetPos+1 ] = u2; - nTargetPos += 2; - nPos2 += 2; - } - } - else - { - // c2 "is more to the left" than c1" - - if( u1 > u2 ) - { - pTarget[ nTargetPos ] = l1; - pTarget[ nTargetPos+1 ] = u2; - nTargetPos += 2; - nPos2 += 2; - } - else - { - pTarget[ nTargetPos ] = l1; - pTarget[ nTargetPos+1 ] = u1; - nTargetPos += 2; - nPos1 += 2; - } - } - }; // while - pTarget[ nTargetPos ] = 0; - - // assign the intersected ranges - delete[] _pRanges; - - sal_uInt16 nUShorts = Count_Impl(pTarget.get()) + 1; - if ( 1 != nUShorts ) - { - _pRanges = new sal_uInt16[ nUShorts ]; - memcpy( _pRanges, pTarget.get(), nUShorts * sizeof(sal_uInt16) ); - } - else - _pRanges = nullptr; - - return *this; -} - -/** * Determines the number of USHORTs in the set described by the ranges * of USHORTs in '*this'. */ |