Skip to content

Commit

Permalink
Make QgsGeos::prepareGeometry and QgsGeos::cacheGeos idempotent
Browse files Browse the repository at this point in the history
Rather than re-preparing or re-converting geometries on every call.
The "geometryChanged" method will reset the caches.
  • Loading branch information
strk authored and nyalldawson committed Sep 20, 2021
1 parent 8051c3f commit 30a56ac
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/geometry/qgsgeos.cpp
Expand Up @@ -212,7 +212,11 @@ void QgsGeos::geometryChanged()

void QgsGeos::prepareGeometry()
{
mGeosPrepared.reset();
if ( mGeosPrepared )
{
// Already prepared
return;
}
if ( mGeos )
{
mGeosPrepared.reset( GEOSPrepare_r( geosinit()->ctxt, mGeos.get() ) );
Expand All @@ -221,6 +225,11 @@ void QgsGeos::prepareGeometry()

void QgsGeos::cacheGeos() const
{
if ( mGeos )
{
// Already cached
return;
}
if ( !mGeometry )
{
return;
Expand Down

0 comments on commit 30a56ac

Please sign in to comment.