Skip to content
Permalink
Browse files

Allow some frequently used methods to be inlined

  • Loading branch information
nyalldawson committed Jun 11, 2018
1 parent 9be7293 commit 82029f9cc8758f2cfbcdae2bd4f4a80fa4d5d871
Showing with 23 additions and 23 deletions.
  1. +2 −21 src/core/raster/qgsrasterrange.cpp
  2. +21 −2 src/core/raster/qgsrasterrange.h
@@ -24,26 +24,7 @@ QgsRasterRange::QgsRasterRange( double min, double max, BoundsType bounds )
{
}

bool QgsRasterRange::contains( double value ) const
{
return ( value > mMin
|| ( !std::isnan( mMin ) && qgsDoubleNear( value, mMin ) && ( mType == IncludeMinAndMax || mType == IncludeMin ) )
|| std::isnan( mMin ) )
&&
( value < mMax
|| ( !std::isnan( mMax ) && qgsDoubleNear( value, mMax ) && ( mType == IncludeMinAndMax || mType == IncludeMax ) )
|| std::isnan( mMax ) );
}

bool QgsRasterRange::contains( double value, const QgsRasterRangeList &rangeList )
{
for ( QgsRasterRange range : rangeList )
{
if ( range.contains( value ) )
{
return true;
}
}
return false;
}



@@ -111,15 +111,34 @@ class CORE_EXPORT QgsRasterRange
* Returns true if this range contains the specified \a value.
* \since QGIS 3.2
*/
bool contains( double value ) const;
bool contains( double value ) const
{
return ( value > mMin
|| ( !std::isnan( mMin ) && qgsDoubleNear( value, mMin ) && ( mType == IncludeMinAndMax || mType == IncludeMin ) )
|| std::isnan( mMin ) )
&&
( value < mMax
|| ( !std::isnan( mMax ) && qgsDoubleNear( value, mMax ) && ( mType == IncludeMinAndMax || mType == IncludeMax ) )
|| std::isnan( mMax ) );
}

/**
* \brief Tests if a \a value is within the list of ranges
* \param value value
* \param rangeList list of ranges
* \returns true if value is in at least one of ranges
*/
static bool contains( double value, const QgsRasterRangeList &rangeList );
static bool contains( double value, const QgsRasterRangeList &rangeList )
{
for ( QgsRasterRange range : rangeList )
{
if ( range.contains( value ) )
{
return true;
}
}
return false;
}

private:
double mMin = std::numeric_limits<double>::quiet_NaN();

0 comments on commit 82029f9

Please sign in to comment.
You can’t perform that action at this time.