diff --git a/common/font/outline_decomposer.cpp b/common/font/outline_decomposer.cpp index 65cca8d1b3..257a1b13d9 100644 --- a/common/font/outline_decomposer.cpp +++ b/common/font/outline_decomposer.cpp @@ -160,6 +160,8 @@ bool OUTLINE_DECOMPOSER::approximateQuadraticBezierCurve( GLYPH_POINTS& aR // cp0 = qp0, cp1 = qp0 + 2/3 * (qp1 - qp0), cp2 = qp2 + 2/3 * (qp1 - qp2), cp3 = qp2 GLYPH_POINTS cubic; + cubic.resize( 4 ); + cubic.push_back( aBezier[0] ); // cp0 cubic.push_back( aBezier[0] + ( ( aBezier[1] - aBezier[0] ) * 2 / 3 ) ); // cp1 cubic.push_back( aBezier[2] + ( ( aBezier[1] - aBezier[2] ) * 2 / 3 ) ); // cp2 diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index 71edaa6dd2..2779dc9a76 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -804,6 +804,8 @@ void GERBER_PLOTTER::Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, { std::vector cornerList; + cornerList.reserve( 5 ); + // Build corners list cornerList.push_back( p1 ); @@ -1526,6 +1528,8 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const V RR_EDGE curr_edge; std::vector rr_outline; + rr_outline.reserve( 4 ); + // Build outline coordinates, relative to rectangle center, rotation 0: // Top left corner 1 (and 4 to 1 left vertical side @ x=-hsizeX) diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index b4d95bcdd5..8b0d18a908 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -144,9 +144,9 @@ void PSLIKE_PLOTTER::FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSiz const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode, void* aData ) { - static std::vector cornerList; + std::vector cornerList; VECTOR2I size( aSize ); - cornerList.clear(); + cornerList.reserve( 4 ); if( aTraceMode == FILLED ) SetCurrentLineWidth( 0 ); diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index 3ff5ad8a36..15ae6e6325 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -253,6 +253,8 @@ void PLOTTER::BezierCurve( const VECTOR2I& aStart, const VECTOR2I& aControl1, int minSegLen = aLineThickness; // The segment min length to approximate a bezier curve std::vector ctrlPoints; + ctrlPoints.reserve( 4 ); + ctrlPoints.push_back( aStart ); ctrlPoints.push_back( aControl1 ); ctrlPoints.push_back( aControl2 ); @@ -295,6 +297,8 @@ void PLOTTER::markerSquare( const VECTOR2I& position, int radius ) std::vector corner_list; VECTOR2I corner; + corner_list.reserve( 4 ); + corner.x = position.x + r; corner.y = position.y + r; corner_list.push_back( corner ); @@ -326,6 +330,8 @@ void PLOTTER::markerLozenge( const VECTOR2I& position, int radius ) std::vector corner_list; VECTOR2I corner; + corner_list.reserve( 4 ); + corner.x = position.x; corner.y = position.y + radius; corner_list.push_back( corner ); diff --git a/pcbnew/router/pns_optimizer.cpp b/pcbnew/router/pns_optimizer.cpp index 31fa3eca6b..51d06b2c9e 100644 --- a/pcbnew/router/pns_optimizer.cpp +++ b/pcbnew/router/pns_optimizer.cpp @@ -820,7 +820,9 @@ OPTIMIZER::BREAKOUT_LIST OPTIMIZER::rectBreakouts( int aWidth, const SHAPE* aSha const SHAPE_RECT* rect = static_cast(aShape); VECTOR2I s = rect->GetSize(); VECTOR2I c = rect->GetPosition() + VECTOR2I( s.x / 2, s.y / 2 ); + BREAKOUT_LIST breakouts; + breakouts.reserve( 12 ); VECTOR2I d_offset;