Skip to content

Commit

Permalink
Allow some frequently used methods to be inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 13, 2018
1 parent 9be7293 commit 82029f9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
23 changes: 2 additions & 21 deletions src/core/raster/qgsrasterrange.cpp
Expand Up @@ -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;
}



23 changes: 21 additions & 2 deletions src/core/raster/qgsrasterrange.h
Expand Up @@ -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();
Expand Down

0 comments on commit 82029f9

Please sign in to comment.