Skip to content

Commit

Permalink
Extra simple fast check of types in equality methods of geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuarte47 authored and nyalldawson committed Dec 5, 2019
1 parent d182cf2 commit 3dadc22
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/geometry/qgsgeometry.cpp
Expand Up @@ -1230,6 +1230,10 @@ bool QgsGeometry::equals( const QgsGeometry &geometry ) const
if ( d == geometry.d )
return true;

// fast check - distinct geometry types?
if ( type() != geometry.type() )
return false;

// slower check - actually test the geometries
return *d->geometry == *geometry.d->geometry;
}
Expand Down Expand Up @@ -2604,6 +2608,10 @@ bool QgsGeometry::isGeosEqual( const QgsGeometry &g ) const
if ( d == g.d )
return true;

// fast check - distinct geometry types?
if ( type() != g.type() )
return false;

// avoid calling geos for trivial point case
if ( QgsWkbTypes::flatType( d->geometry->wkbType() ) == QgsWkbTypes::Point
&& QgsWkbTypes::flatType( g.d->geometry->wkbType() ) == QgsWkbTypes::Point )
Expand Down

0 comments on commit 3dadc22

Please sign in to comment.