Skip to content
Permalink
Browse files

Merge pull request #6300 from nyalldawson/opts

Misc optimizations for everything
  • Loading branch information
nyalldawson committed Feb 12, 2018
2 parents 2cbcf74 + 24fb28f commit 46d7a4280cd9a37b86af4ccf9adc84fe0008f205
Showing with 181 additions and 92 deletions.
  1. +2 −2 python/core/geometry/qgsabstractgeometry.sip.in
  2. +3 −1 python/core/geometry/qgscircularstring.sip.in
  3. +3 −2 python/core/geometry/qgscompoundcurve.sip.in
  4. +4 −1 python/core/geometry/qgscurvepolygon.sip.in
  5. +2 −1 python/core/geometry/qgsgeometrycollection.sip.in
  6. +4 −1 python/core/geometry/qgslinestring.sip.in
  7. +1 −2 python/core/geometry/qgsmulticurve.sip.in
  8. +4 −1 python/core/geometry/qgsmultilinestring.sip.in
  9. +4 −1 python/core/geometry/qgsmultipoint.sip.in
  10. +3 −1 python/core/geometry/qgsmultipolygon.sip.in
  11. +0 −1 python/core/geometry/qgsmultisurface.sip.in
  12. +3 −1 python/core/geometry/qgspoint.sip.in
  13. +2 −2 python/core/geometry/qgspolygon.sip.in
  14. +4 −1 python/core/geometry/qgsrectangle.sip.in
  15. +1 −2 python/core/geometry/qgstriangle.sip.in
  16. +2 −2 src/core/geometry/qgsabstractgeometry.h
  17. +3 −1 src/core/geometry/qgscircularstring.h
  18. +2 −1 src/core/geometry/qgscompoundcurve.h
  19. +4 −1 src/core/geometry/qgscurvepolygon.h
  20. +24 −13 src/core/geometry/qgsgeometry.cpp
  21. +2 −1 src/core/geometry/qgsgeometrycollection.h
  22. +4 −1 src/core/geometry/qgslinestring.h
  23. +1 −2 src/core/geometry/qgsmulticurve.h
  24. +4 −1 src/core/geometry/qgsmultilinestring.h
  25. +4 −1 src/core/geometry/qgsmultipoint.h
  26. +3 −1 src/core/geometry/qgsmultipolygon.h
  27. +0 −1 src/core/geometry/qgsmultisurface.h
  28. +3 −1 src/core/geometry/qgspoint.h
  29. +2 −2 src/core/geometry/qgspolygon.h
  30. +1 −0 src/core/geometry/qgsrectangle.cpp
  31. +9 −5 src/core/geometry/qgsrectangle.h
  32. +1 −2 src/core/geometry/qgstriangle.h
  33. +45 −21 src/core/qgsmaptopixelgeometrysimplifier.cpp
  34. +26 −14 src/core/symbology/qgssymbol.cpp
  35. +1 −1 src/providers/wfs/qgswfsshareddata.cpp
@@ -596,8 +596,6 @@ Returns Java-style iterator for traversal of vertices of the geometry
.. versionadded:: 3.0
%End

protected:

virtual QgsAbstractGeometry *createEmptyWithSameType() const = 0 /Factory/;
%Docstring
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
@@ -612,6 +610,8 @@ To create it, the geometry is default constructed and then the WKB is changed.
Not available in Python bindings
%End

protected:

virtual bool hasChildGeometries() const;
%Docstring
Returns whether the geometry has any child geometries (false for point / curve, true otherwise)
@@ -127,9 +127,11 @@ Sets the circular string's points
virtual double yAt( int index ) const;


protected:
virtual QgsCircularString *createEmptyWithSameType() const /Factory/;


protected:

virtual QgsRectangle calculateBoundingBox() const;


@@ -160,12 +160,13 @@ Appends first point if not already closed.
virtual double yAt( int index ) const;


virtual QgsCompoundCurve *createEmptyWithSameType() const /Factory/;


protected:

virtual QgsRectangle calculateBoundingBox() const;

virtual QgsCompoundCurve *createEmptyWithSameType() const /Factory/;


};

@@ -198,9 +198,12 @@ Returns approximate rotation angle for a vertex. Usually average angle between a

virtual QgsCurvePolygon *toCurveType() const /Factory/;

protected:

virtual QgsCurvePolygon *createEmptyWithSameType() const /Factory/;


protected:

virtual int childCount() const;

virtual QgsAbstractGeometry *childGeometry( int index ) const;
@@ -176,9 +176,10 @@ Returns a geometry without curves. Caller takes ownership



protected:
virtual QgsGeometryCollection *createEmptyWithSameType() const /Factory/;


protected:
virtual int childCount() const;

virtual QgsAbstractGeometry *childGeometry( int index ) const;
@@ -290,9 +290,12 @@ of the curve.
virtual bool convertTo( QgsWkbTypes::Type type );


protected:

virtual QgsLineString *createEmptyWithSameType() const /Factory/;


protected:

virtual QgsRectangle calculateBoundingBox() const;


@@ -53,11 +53,10 @@ Returns a copy of the multi curve, where each component curve has had its line d



protected:

virtual QgsMultiCurve *createEmptyWithSameType() const /Factory/;



};


@@ -49,9 +49,12 @@ Returns the geometry converted to the more generic curve type :py:class:`QgsMult
:return: the converted geometry. Caller takes ownership*
%End

protected:

virtual QgsMultiLineString *createEmptyWithSameType() const /Factory/;


protected:

virtual bool wktOmitChildType() const;

};
@@ -51,9 +51,12 @@ class QgsMultiPoint: QgsGeometryCollection
virtual double segmentLength( QgsVertexId startVertex ) const;


protected:

virtual QgsMultiPoint *createEmptyWithSameType() const /Factory/;


protected:

virtual bool wktOmitChildType() const;


@@ -51,9 +51,11 @@ Returns the geometry converted to the more generic curve type :py:class:`QgsMult
virtual QgsAbstractGeometry *boundary() const /Factory/;


protected:
virtual QgsMultiPolygon *createEmptyWithSameType() const /Factory/;


protected:

virtual bool wktOmitChildType() const;

};
@@ -45,7 +45,6 @@ class QgsMultiSurface: QgsGeometryCollection



protected:
virtual QgsMultiSurface *createEmptyWithSameType() const /Factory/;


@@ -419,9 +419,11 @@ Angle undefined. Always returns 0.0



protected:
virtual QgsPoint *createEmptyWithSameType() const /Factory/;


protected:

virtual int childCount() const;

virtual QgsPoint childPoint( int index ) const;
@@ -62,11 +62,11 @@ negative if the point lies outside the polygon.
%End


protected:

virtual QgsPolygon *createEmptyWithSameType() const /Factory/;


protected:


};
/************************************************************************
@@ -26,7 +26,10 @@ Examples are storing a layer extent or the current view extent of a map
#include "qgsrectangle.h"
%End
public:
QgsRectangle( double xMin = 0, double yMin = 0, double xMax = 0, double yMax = 0 );

QgsRectangle(); // optimised constructor for null rectangle - no need to call normalize here

explicit QgsRectangle( double xMin, double yMin = 0, double xMax = 0, double yMax = 0 );
%Docstring
Constructor
%End
@@ -425,11 +425,10 @@ Example:
%End


protected:

virtual QgsTriangle *createEmptyWithSameType() const /Factory/;



};
/************************************************************************
* This file has been generated automatically from *
@@ -617,8 +617,6 @@ class CORE_EXPORT QgsAbstractGeometry
*/
QgsVertexIterator vertices() const;

protected:

/**
* Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
* To create it, the geometry is default constructed and then the WKB is changed.
@@ -628,6 +626,8 @@ class CORE_EXPORT QgsAbstractGeometry
*/
virtual QgsAbstractGeometry *createEmptyWithSameType() const = 0 SIP_FACTORY;

protected:

/**
* Returns whether the geometry has any child geometries (false for point / curve, true otherwise)
* \note used for vertex_iterator implementation
@@ -113,8 +113,10 @@ class CORE_EXPORT QgsCircularString: public QgsCurve
}
#endif

protected:
QgsCircularString *createEmptyWithSameType() const override SIP_FACTORY;

protected:

QgsRectangle calculateBoundingBox() const override;

private:
@@ -142,10 +142,11 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve
}
#endif

QgsCompoundCurve *createEmptyWithSameType() const override SIP_FACTORY;

protected:

QgsRectangle calculateBoundingBox() const override;
QgsCompoundCurve *createEmptyWithSameType() const override SIP_FACTORY;

private:
QVector< QgsCurve * > mCurves;
@@ -175,8 +175,11 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface
return nullptr;
}
#endif
protected:

QgsCurvePolygon *createEmptyWithSameType() const override SIP_FACTORY;

protected:

int childCount() const override;
QgsAbstractGeometry *childGeometry( int index ) const override;

@@ -223,17 +223,20 @@ QgsGeometry QgsGeometry::fromMultiPolygonXY( const QgsMultiPolygonXY &multipoly

QgsGeometry QgsGeometry::fromRect( const QgsRectangle &rect )
{
QgsPolylineXY ring;
ring.append( QgsPointXY( rect.xMinimum(), rect.yMinimum() ) );
ring.append( QgsPointXY( rect.xMaximum(), rect.yMinimum() ) );
ring.append( QgsPointXY( rect.xMaximum(), rect.yMaximum() ) );
ring.append( QgsPointXY( rect.xMinimum(), rect.yMaximum() ) );
ring.append( QgsPointXY( rect.xMinimum(), rect.yMinimum() ) );

QgsPolygonXY polygon;
polygon.append( ring );

return fromPolygonXY( polygon );
std::unique_ptr< QgsLineString > ext = qgis::make_unique< QgsLineString >(
QVector< double >() << rect.xMinimum()
<< rect.xMaximum()
<< rect.xMaximum()
<< rect.xMinimum()
<< rect.xMinimum(),
QVector< double >() << rect.yMinimum()
<< rect.yMinimum()
<< rect.yMaximum()
<< rect.yMaximum()
<< rect.yMinimum() );
std::unique_ptr< QgsPolygon > polygon = qgis::make_unique< QgsPolygon >();
polygon->setExteriorRing( ext.release() );
return QgsGeometry( std::move( polygon ) );
}

QgsGeometry QgsGeometry::collectGeometry( const QVector< QgsGeometry > &geometries )
@@ -1258,8 +1261,16 @@ bool QgsGeometry::convertToMultiType()
return false;
}

multiGeom->addGeometry( d->geometry->clone() );
reset( std::move( geom ) );
//try to avoid cloning existing geometry whenever we can

//want to see a magic trick?... gather round kiddies...
detach(); // maybe a clone, hopefully not if we're the only ref to the private data
// now we cheat a bit and steal the private geometry and add it direct to the multigeom
// we can do this because we're the only ref to this geometry, guaranteed by the detach call above
multiGeom->addGeometry( d->geometry.release() );
// and replace it with the multi geometry.
// TADA! a clone free conversion in some cases
d->geometry = std::move( geom );
return true;
}

@@ -159,8 +159,9 @@ class CORE_EXPORT QgsGeometryCollection: public QgsAbstractGeometry
}
#endif

protected:
QgsGeometryCollection *createEmptyWithSameType() const override SIP_FACTORY;

protected:
int childCount() const override;
QgsAbstractGeometry *childGeometry( int index ) const override;

@@ -253,8 +253,11 @@ class CORE_EXPORT QgsLineString: public QgsCurve
return nullptr;
}
#endif
protected:

QgsLineString *createEmptyWithSameType() const override SIP_FACTORY;

protected:

QgsRectangle calculateBoundingBox() const override;

private:
@@ -71,10 +71,9 @@ class CORE_EXPORT QgsMultiCurve: public QgsGeometryCollection
}
#endif

protected:

QgsMultiCurve *createEmptyWithSameType() const override SIP_FACTORY;


};

// clazy:excludeall=qstring-allocations
@@ -62,8 +62,11 @@ class CORE_EXPORT QgsMultiLineString: public QgsMultiCurve
return nullptr;
}
#endif
protected:

QgsMultiLineString *createEmptyWithSameType() const override SIP_FACTORY;

protected:

bool wktOmitChildType() const override;
};

@@ -62,8 +62,11 @@ class CORE_EXPORT QgsMultiPoint: public QgsGeometryCollection
return nullptr;
}
#endif
protected:

QgsMultiPoint *createEmptyWithSameType() const override SIP_FACTORY;

protected:

bool wktOmitChildType() const override;

};
@@ -63,8 +63,10 @@ class CORE_EXPORT QgsMultiPolygon: public QgsMultiSurface
}
#endif

protected:
QgsMultiPolygon *createEmptyWithSameType() const override SIP_FACTORY;

protected:

bool wktOmitChildType() const override;
};

@@ -65,7 +65,6 @@ class CORE_EXPORT QgsMultiSurface: public QgsGeometryCollection
}
#endif

protected:
QgsMultiSurface *createEmptyWithSameType() const override SIP_FACTORY;

};

0 comments on commit 46d7a42

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