Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Optimise QgsGeometryPrivate constructors to avoid unnecessary extra work
  • Loading branch information
nyalldawson committed May 9, 2023
1 parent beceade commit e33996d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/core/geometry/qgsgeometry.cpp
Expand Up @@ -49,6 +49,7 @@ email : morb at ozemail dot com dot au
struct QgsGeometryPrivate
{
QgsGeometryPrivate(): ref( 1 ) {}
QgsGeometryPrivate( std::unique_ptr< QgsAbstractGeometry > geometry ): ref( 1 ), geometry( std::move( geometry ) ) {}
QAtomicInt ref;
std::unique_ptr< QgsAbstractGeometry > geometry;
};
Expand All @@ -68,14 +69,11 @@ QgsGeometry::QgsGeometry( QgsAbstractGeometry *geom )
: d( new QgsGeometryPrivate() )
{
d->geometry.reset( geom );
d->ref = QAtomicInt( 1 );
}

QgsGeometry::QgsGeometry( std::unique_ptr<QgsAbstractGeometry> geom )
: d( new QgsGeometryPrivate() )
: d( new QgsGeometryPrivate( std::move( geom ) ) )
{
d->geometry = std::move( geom );
d->ref = QAtomicInt( 1 );
}

QgsGeometry::QgsGeometry( const QgsGeometry &other )
Expand Down

0 comments on commit e33996d

Please sign in to comment.