@@ -1658,6 +1658,7 @@ QgsGeometry QgsGeometry::offsetCurve( double distance, int segments, JoinStyle j
1658
1658
{
1659
1659
const QVector<QgsGeometry> parts = asGeometryCollection ();
1660
1660
QVector<QgsGeometry> results;
1661
+ results.reserve ( parts.count () );
1661
1662
for ( const QgsGeometry &part : parts )
1662
1663
{
1663
1664
QgsGeometry result = part.offsetCurve ( distance, segments, joinStyle, miterLimit );
@@ -1700,6 +1701,7 @@ QgsGeometry QgsGeometry::singleSidedBuffer( double distance, int segments, Buffe
1700
1701
{
1701
1702
const QVector<QgsGeometry> parts = asGeometryCollection ();
1702
1703
QVector<QgsGeometry> results;
1704
+ results.reserve ( parts.count () );
1703
1705
for ( const QgsGeometry &part : parts )
1704
1706
{
1705
1707
QgsGeometry result = part.singleSidedBuffer ( distance, segments, side, joinStyle, miterLimit );
@@ -1743,6 +1745,7 @@ QgsGeometry QgsGeometry::extendLine( double startDistance, double endDistance )
1743
1745
{
1744
1746
const QVector<QgsGeometry> parts = asGeometryCollection ();
1745
1747
QVector<QgsGeometry> results;
1748
+ results.reserve ( parts.count () );
1746
1749
for ( const QgsGeometry &part : parts )
1747
1750
{
1748
1751
QgsGeometry result = part.extendLine ( startDistance, endDistance );
@@ -2176,6 +2179,7 @@ QPolygonF QgsGeometry::asQPolygonF() const
2176
2179
return result;
2177
2180
}
2178
2181
2182
+ result.reserve ( polyline.count () );
2179
2183
for ( const QgsPointXY &p : qgis::as_const ( polyline ) )
2180
2184
{
2181
2185
result << p.toQPointF ();
@@ -2604,6 +2608,7 @@ QgsPolygonXY QgsGeometry::createPolygonFromQPolygonF( const QPolygonF &polygon )
2604
2608
QgsPolylineXY QgsGeometry::createPolylineFromQPolygonF ( const QPolygonF &polygon )
2605
2609
{
2606
2610
QgsPolylineXY result;
2611
+ result.reserve ( polygon.count () );
2607
2612
for ( const QPointF &p : polygon )
2608
2613
{
2609
2614
result.append ( QgsPointXY ( p ) );
@@ -2714,9 +2719,10 @@ std::unique_ptr< QgsLineString > smoothCurve( const QgsLineString &line, const u
2714
2719
bool isRing )
2715
2720
{
2716
2721
std::unique_ptr< QgsLineString > result = qgis::make_unique< QgsLineString >( line );
2722
+ QgsPointSequence outputLine;
2717
2723
for ( unsigned int iteration = 0 ; iteration < iterations; ++iteration )
2718
2724
{
2719
- QgsPointSequence outputLine;
2725
+ outputLine. resize ( 0 ) ;
2720
2726
outputLine.reserve ( 2 * ( result->numPoints () - 1 ) );
2721
2727
bool skipFirst = false ;
2722
2728
bool skipLast = false ;
@@ -2990,6 +2996,7 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
2990
2996
{
2991
2997
const QgsPolygonXY polygon = asPolygon ();
2992
2998
QgsMultiPolylineXY multiLine;
2999
+ multiLine.reserve ( polygon.count () );
2993
3000
for ( const QgsPolylineXY &line : polygon )
2994
3001
multiLine << line;
2995
3002
return fromMultiPolylineXY ( multiLine );
0 commit comments