@@ -1658,6 +1658,7 @@ QgsGeometry QgsGeometry::offsetCurve( double distance, int segments, JoinStyle j
16581658 {
16591659 const QVector<QgsGeometry> parts = asGeometryCollection ();
16601660 QVector<QgsGeometry> results;
1661+ results.reserve ( parts.count () );
16611662 for ( const QgsGeometry &part : parts )
16621663 {
16631664 QgsGeometry result = part.offsetCurve ( distance, segments, joinStyle, miterLimit );
@@ -1700,6 +1701,7 @@ QgsGeometry QgsGeometry::singleSidedBuffer( double distance, int segments, Buffe
17001701 {
17011702 const QVector<QgsGeometry> parts = asGeometryCollection ();
17021703 QVector<QgsGeometry> results;
1704+ results.reserve ( parts.count () );
17031705 for ( const QgsGeometry &part : parts )
17041706 {
17051707 QgsGeometry result = part.singleSidedBuffer ( distance, segments, side, joinStyle, miterLimit );
@@ -1743,6 +1745,7 @@ QgsGeometry QgsGeometry::extendLine( double startDistance, double endDistance )
17431745 {
17441746 const QVector<QgsGeometry> parts = asGeometryCollection ();
17451747 QVector<QgsGeometry> results;
1748+ results.reserve ( parts.count () );
17461749 for ( const QgsGeometry &part : parts )
17471750 {
17481751 QgsGeometry result = part.extendLine ( startDistance, endDistance );
@@ -2176,6 +2179,7 @@ QPolygonF QgsGeometry::asQPolygonF() const
21762179 return result;
21772180 }
21782181
2182+ result.reserve ( polyline.count () );
21792183 for ( const QgsPointXY &p : qgis::as_const ( polyline ) )
21802184 {
21812185 result << p.toQPointF ();
@@ -2604,6 +2608,7 @@ QgsPolygonXY QgsGeometry::createPolygonFromQPolygonF( const QPolygonF &polygon )
26042608QgsPolylineXY QgsGeometry::createPolylineFromQPolygonF ( const QPolygonF &polygon )
26052609{
26062610 QgsPolylineXY result;
2611+ result.reserve ( polygon.count () );
26072612 for ( const QPointF &p : polygon )
26082613 {
26092614 result.append ( QgsPointXY ( p ) );
@@ -2714,9 +2719,10 @@ std::unique_ptr< QgsLineString > smoothCurve( const QgsLineString &line, const u
27142719 bool isRing )
27152720{
27162721 std::unique_ptr< QgsLineString > result = qgis::make_unique< QgsLineString >( line );
2722+ QgsPointSequence outputLine;
27172723 for ( unsigned int iteration = 0 ; iteration < iterations; ++iteration )
27182724 {
2719- QgsPointSequence outputLine;
2725+ outputLine. resize ( 0 ) ;
27202726 outputLine.reserve ( 2 * ( result->numPoints () - 1 ) );
27212727 bool skipFirst = false ;
27222728 bool skipLast = false ;
@@ -2990,6 +2996,7 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
29902996 {
29912997 const QgsPolygonXY polygon = asPolygon ();
29922998 QgsMultiPolylineXY multiLine;
2999+ multiLine.reserve ( polygon.count () );
29933000 for ( const QgsPolylineXY &line : polygon )
29943001 multiLine << line;
29953002 return fromMultiPolylineXY ( multiLine );
0 commit comments