mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-19 14:11:41 +00:00
Cleanup: Replace push_back with emplace_back
In cases where we create a new item and immediately push into a container, the emplace idiom is faster and more efficient.
This commit is contained in:
parent
6f8b399c5f
commit
b5f021ff9f
3d-viewer
3d_cache/sg
3d_rendering
3d_render_ogl_legacy
3d_render_raytracing
common
basic_gal.cppeagle_parser.cppfilename_resolver.cpp
gal/opengl
geometry
gr_basic.cppmarker_base.cpppage_layout
plotters
widgets
dxflib_qcad
eeschema
gerbview
include
kicad
pcbnew
class_board.cppclass_drawsegment.cppclass_edge_mod.cppclass_pad.cppclass_pcb_text.cppclass_text_mod.cppclass_track.cpp
dialogs
eagle_plugin.cppexporters
footprint_info_impl.cppimport_gfx
legacy_plugin.cppnetinfo_item.cpppad_custom_shape_functions.cpppcb_draw_panel_gal.cpppcb_general_settings.cppratsnest_data.cpprouter
plugins/3d
polygon
qa/common/geometry
utils/idftools
@ -185,7 +185,7 @@ void SGCOLORS::SetColorList( size_t aListSize, const SGCOLOR* aColorList )
|
||||
|
||||
void SGCOLORS::AddColor( double aRedValue, double aGreenValue, double aBlueValue )
|
||||
{
|
||||
colors.push_back( SGCOLOR( aRedValue, aGreenValue, aBlueValue ) );
|
||||
colors.emplace_back( aRedValue, aGreenValue, aBlueValue );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ void SGCOORDS::SetCoordsList( size_t aListSize, const SGPOINT* aCoordsList )
|
||||
|
||||
void SGCOORDS::AddCoord( double aXValue, double aYValue, double aZValue )
|
||||
{
|
||||
coords.push_back( SGPOINT( aXValue, aYValue, aZValue ) );
|
||||
coords.emplace_back( aXValue, aYValue, aZValue );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -503,7 +503,7 @@ bool S3D::CalcTriangleNormals( std::vector< SGPOINT > coords,
|
||||
// assign any skipped coordinates a normal of (0,0,1)
|
||||
while( item > idx )
|
||||
{
|
||||
norms.push_back( SGVECTOR( 0, 0, 1 ) );
|
||||
norms.emplace_back( 0, 0, 1 );
|
||||
++idx;
|
||||
}
|
||||
|
||||
@ -517,7 +517,7 @@ bool S3D::CalcTriangleNormals( std::vector< SGPOINT > coords,
|
||||
++sT;
|
||||
}
|
||||
|
||||
norms.push_back( SGVECTOR( norm.x, norm.y, norm.z ) );
|
||||
norms.emplace_back( norm.x, norm.y, norm.z );
|
||||
|
||||
++idx;
|
||||
++sM;
|
||||
|
@ -186,7 +186,7 @@ void SGNORMALS::SetNormalList( size_t aListSize, const SGVECTOR* aNormalList )
|
||||
|
||||
void SGNORMALS::AddNormal( double aXValue, double aYValue, double aZValue )
|
||||
{
|
||||
norms.push_back( SGVECTOR( aXValue, aYValue, aZValue ) );
|
||||
norms.emplace_back( aXValue, aYValue, aZValue );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -112,11 +112,11 @@ void C3D_RENDER_OGL_LEGACY::generate_ring_contour( const SFVEC2F &aCenter,
|
||||
* 2.0f * glm::pi<float>() / 3600.0f;
|
||||
const SFVEC2F rotatedDir = SFVEC2F( cos( angle ), sin( angle ) );
|
||||
|
||||
aInnerContourResult.push_back( SFVEC2F( aCenter.x + rotatedDir.x * aInnerRadius,
|
||||
aCenter.y + rotatedDir.y * aInnerRadius ) );
|
||||
aInnerContourResult.emplace_back( aCenter.x + rotatedDir.x * aInnerRadius,
|
||||
aCenter.y + rotatedDir.y * aInnerRadius );
|
||||
|
||||
aOuterContourResult.push_back( SFVEC2F( aCenter.x + rotatedDir.x * aOuterRadius,
|
||||
aCenter.y + rotatedDir.y * aOuterRadius ) );
|
||||
aOuterContourResult.emplace_back( aCenter.x + rotatedDir.x * aOuterRadius,
|
||||
aCenter.y + rotatedDir.y * aOuterRadius );
|
||||
}
|
||||
|
||||
aInnerContourResult.push_back( aInnerContourResult[0] );
|
||||
|
@ -2141,7 +2141,7 @@ void C3D_RENDER_RAYTRACING::initialize_block_positions()
|
||||
|
||||
for( int x = 0; x < blocks_x; ++x )
|
||||
for( int y = 0; y < blocks_y; ++y )
|
||||
m_blockPositions.push_back( SFVEC2UI( x * RAYPACKET_DIM, y * RAYPACKET_DIM ) );
|
||||
m_blockPositions.emplace_back( x * RAYPACKET_DIM, y * RAYPACKET_DIM );
|
||||
|
||||
const SFVEC2UI center( m_realBufferSize.x / 2, m_realBufferSize.y / 2 );
|
||||
std::sort( m_blockPositions.begin(), m_blockPositions.end(),
|
||||
|
@ -62,7 +62,7 @@ void BASIC_GAL::DrawPolyline( const std::deque<VECTOR2D>& aPointList )
|
||||
for( ; it != aPointList.end(); ++it )
|
||||
{
|
||||
VECTOR2D corner = transform(*it);
|
||||
polyline_corners.push_back( wxPoint( corner.x, corner.y ) );
|
||||
polyline_corners.emplace_back( corner.x, corner.y );
|
||||
}
|
||||
|
||||
if( m_DC )
|
||||
|
@ -1035,7 +1035,7 @@ EDEVICE::EDEVICE( wxXmlNode* aDevice )
|
||||
|
||||
while( connectNode )
|
||||
{
|
||||
connects.push_back( ECONNECT( connectNode ) );
|
||||
connects.emplace_back( connectNode );
|
||||
connectNode = connectNode->GetNext();
|
||||
}
|
||||
}
|
||||
|
@ -1071,7 +1071,7 @@ bool FILENAME_RESOLVER::GetKicadPaths( std::list< wxString >& paths )
|
||||
}
|
||||
|
||||
if( !hasKisys3D )
|
||||
paths.push_back( "${KISYS3DMOD}" );
|
||||
paths.emplace_back("${KISYS3DMOD}" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ void CACHED_CONTAINER::mergeFreeChunks()
|
||||
|
||||
for( it = m_freeChunks.begin(), it_end = m_freeChunks.end(); it != it_end; ++it )
|
||||
{
|
||||
freeChunks.push_back( std::make_pair( it->second, it->first ) );
|
||||
freeChunks.emplace_back( it->second, it->first );
|
||||
}
|
||||
|
||||
m_freeChunks.clear();
|
||||
|
@ -2065,7 +2065,7 @@ void CALLBACK CombineCallback( GLdouble coords[3],
|
||||
OPENGL_GAL::TessParams* param = static_cast<OPENGL_GAL::TessParams*>( aData );
|
||||
|
||||
// Save the pointer so we can delete it later
|
||||
param->intersectPoints.push_back( boost::shared_array<GLdouble>( vertex ) );
|
||||
param->intersectPoints.emplace_back( vertex );
|
||||
|
||||
memcpy( vertex, coords, 3 * sizeof(GLdouble) );
|
||||
|
||||
|
@ -151,7 +151,7 @@ void BuildConvexHull( std::vector<wxPoint>& aResult,
|
||||
|
||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||
{
|
||||
buf.push_back( wxPoint( poly.CPoint( ii ).x, poly.CPoint( ii ).y ) );
|
||||
buf.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ bool SHAPE_LINE_CHAIN::Parse( std::stringstream& aStream )
|
||||
int x, y;
|
||||
aStream >> x;
|
||||
aStream >> y;
|
||||
m_points.push_back( VECTOR2I( x, y ) );
|
||||
m_points.emplace_back( x, y );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -985,7 +985,7 @@ void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPoints[], int n )
|
||||
|
||||
for( cpointIterator cit = outputPolygon.begin(); cit != outputPolygon.end(); ++cit )
|
||||
{
|
||||
clippedPolygon.push_back( wxPoint( KiROUND( cit->X ), KiROUND( cit->Y ) ) );
|
||||
clippedPolygon.emplace_back( KiROUND( cit->X ), KiROUND( cit->Y ) );
|
||||
}
|
||||
|
||||
if( clippedPolygon.size() )
|
||||
|
@ -246,8 +246,8 @@ void MARKER_BASE::PrintMarker( wxDC* aDC, const wxPoint& aOffset )
|
||||
|
||||
for( int ii = 0; ii < ccount; ii++ )
|
||||
{
|
||||
shape.push_back( wxPoint( GetShapePolygonCorner( ii ).x * MarkerScale(),
|
||||
GetShapePolygonCorner( ii ).y * MarkerScale() ) );
|
||||
shape.emplace_back( GetShapePolygonCorner( ii ).x * MarkerScale(),
|
||||
GetShapePolygonCorner( ii ).y * MarkerScale() );
|
||||
}
|
||||
|
||||
for( int ii = 0; ii < ccount; ii++ )
|
||||
|
@ -200,8 +200,8 @@ void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( wxDC* aDC, const wxPoint& aOffset,
|
||||
SHAPE_LINE_CHAIN& outline = m_Polygons.Outline( idx );
|
||||
|
||||
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
||||
points_moved.push_back( wxPoint( outline.Point( ii ).x + aOffset.x,
|
||||
outline.Point( ii ).y + aOffset.y ) );
|
||||
points_moved.emplace_back( outline.Point( ii ).x + aOffset.x,
|
||||
outline.Point( ii ).y + aOffset.y );
|
||||
|
||||
GRPoly( nullptr, aDC, points_moved.size(), &points_moved[0], FILLED_SHAPE,
|
||||
GetPenWidth(), aColor, aColor );
|
||||
|
@ -619,7 +619,7 @@ void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int
|
||||
const SHAPE_LINE_CHAIN& path = outlineBuffer.COutline(0 );
|
||||
|
||||
for( int jj = 0; jj < path.PointCount(); jj++ )
|
||||
cornerList.push_back( wxPoint( path.CPoint( jj ).x , path.CPoint( jj ).y ) );
|
||||
cornerList.emplace_back( path.CPoint( jj ).x , path.CPoint( jj ).y );
|
||||
|
||||
// Ensure the polygon is closed
|
||||
if( cornerList[0] != cornerList[cornerList.size() - 1] )
|
||||
|
@ -902,7 +902,7 @@ void GERBER_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aS
|
||||
cornerList.reserve( poly.PointCount() + 1 );
|
||||
|
||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
|
||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
||||
|
||||
// Close polygon
|
||||
cornerList.push_back( cornerList[0] );
|
||||
@ -942,7 +942,7 @@ void GERBER_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize
|
||||
cornerList.clear();
|
||||
|
||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
|
||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
||||
|
||||
// Close polygon
|
||||
cornerList.push_back( cornerList[0] );
|
||||
|
@ -603,12 +603,12 @@ void HPGL_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& padsize,
|
||||
}
|
||||
|
||||
|
||||
corners.push_back( wxPoint( - dx, - dy ) );
|
||||
corners.push_back( wxPoint( - dx, + dy ) );
|
||||
corners.push_back( wxPoint( + dx, + dy ) );
|
||||
corners.push_back( wxPoint( + dx, - dy ) );
|
||||
corners.emplace_back( - dx, - dy );
|
||||
corners.emplace_back( - dx, + dy );
|
||||
corners.emplace_back( + dx, + dy );
|
||||
corners.emplace_back( + dx, - dy );
|
||||
// Close polygon
|
||||
corners.push_back( wxPoint( - dx, - dy ) );
|
||||
corners.emplace_back( - dx, - dy );
|
||||
|
||||
for( unsigned ii = 0; ii < corners.size(); ii++ )
|
||||
{
|
||||
@ -649,7 +649,7 @@ void HPGL_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSiz
|
||||
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
|
||||
|
||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
|
||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
||||
|
||||
if( cornerList.back() != cornerList.front() )
|
||||
cornerList.push_back( cornerList.front() );
|
||||
@ -671,7 +671,7 @@ void HPGL_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
||||
cornerList.reserve( poly.PointCount() );
|
||||
|
||||
for( int ii = 1; ii < poly.PointCount(); ++ii )
|
||||
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
|
||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
||||
|
||||
if( cornerList.back() != cornerList.front() )
|
||||
cornerList.push_back( cornerList.front() );
|
||||
|
@ -208,7 +208,7 @@ void PSLIKE_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aS
|
||||
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
|
||||
|
||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
|
||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
||||
|
||||
// Close polygon
|
||||
cornerList.push_back( cornerList[0] );
|
||||
@ -241,7 +241,7 @@ void PSLIKE_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize
|
||||
cornerList.clear();
|
||||
|
||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
|
||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
||||
|
||||
// Close polygon
|
||||
cornerList.push_back( cornerList[0] );
|
||||
|
@ -126,8 +126,8 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
|
||||
SHAPE_LINE_CHAIN& outline = poly->GetPolygons().Outline( idx );
|
||||
|
||||
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
||||
points.push_back( wxPoint( outline.Point( ii ).x ,
|
||||
outline.Point( ii ).y ) );
|
||||
points.emplace_back( outline.Point( ii ).x ,
|
||||
outline.Point( ii ).y );
|
||||
|
||||
plotter->PlotPoly( points, FILLED_SHAPE, poly->GetPenWidth() );
|
||||
}
|
||||
|
@ -577,10 +577,10 @@ void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill,
|
||||
std::vector< wxPoint > cornerList;
|
||||
|
||||
for( int ii = 0; ii < aCornerList.PointCount(); ii++ )
|
||||
cornerList.push_back( wxPoint( aCornerList.CPoint( ii ) ) );
|
||||
cornerList.emplace_back( aCornerList.CPoint( ii ) );
|
||||
|
||||
if( aCornerList.IsClosed() && cornerList.front() != cornerList.back() )
|
||||
cornerList.push_back( wxPoint( aCornerList.CPoint( 0 ) ) );
|
||||
cornerList.emplace_back( aCornerList.CPoint( 0 ) );
|
||||
|
||||
PlotPoly( cornerList , aFill, aWidth, aData );
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ void mpScaleX::recalculateTicks( wxDC& dc, mpWindow& w )
|
||||
|
||||
for( double t : m_tickValues )
|
||||
{
|
||||
m_tickLabels.push_back( TickLabel( t ) );
|
||||
m_tickLabels.emplace_back( t );
|
||||
}
|
||||
|
||||
updateTickLabels( dc, w );
|
||||
@ -1103,7 +1103,7 @@ void mpScaleY::computeSlaveTicks( mpWindow& w )
|
||||
{
|
||||
m = TransformFromPlot( m_masterScale->TransformToPlot( m_masterScale->m_tickValues[i] ) );
|
||||
m_tickValues.push_back( m );
|
||||
m_tickLabels.push_back( TickLabel( m ) );
|
||||
m_tickLabels.emplace_back( m );
|
||||
m_absVisibleMaxV = std::max( m_absVisibleMaxV, fabs( m ) );
|
||||
}
|
||||
}
|
||||
@ -1190,7 +1190,7 @@ void mpScaleY::recalculateTicks( wxDC& dc, mpWindow& w )
|
||||
}
|
||||
|
||||
for( double t : m_tickValues )
|
||||
m_tickLabels.push_back( TickLabel( t ) );
|
||||
m_tickLabels.emplace_back( t );
|
||||
|
||||
|
||||
// n0 = floor(minVvis / bestStep) * bestStep;
|
||||
@ -1246,12 +1246,12 @@ void mpScaleXLog::recalculateTicks( wxDC& dc, mpWindow& w )
|
||||
for( d = minDecade; d<=maxDecade; d *= 10.0 )
|
||||
{
|
||||
// printf("d %.1f\n",d );
|
||||
m_tickLabels.push_back( TickLabel( d ) );
|
||||
m_tickLabels.emplace_back( d );
|
||||
|
||||
for( double dd = d; dd < d * 10; dd += d )
|
||||
{
|
||||
if( visibleDecades < 2 )
|
||||
m_tickLabels.push_back( TickLabel( dd ) );
|
||||
m_tickLabels.emplace_back( dd );
|
||||
|
||||
m_tickValues.push_back( dd );
|
||||
}
|
||||
|
@ -2310,7 +2310,7 @@ void DL_Dxf::addHatch( DL_CreationInterface* creationInterface )
|
||||
void DL_Dxf::addHatchLoop()
|
||||
{
|
||||
addHatchEdge();
|
||||
hatchEdges.push_back( std::vector<DL_HatchEdgeData>() );
|
||||
hatchEdges.emplace_back( );
|
||||
}
|
||||
|
||||
|
||||
@ -2384,7 +2384,7 @@ bool DL_Dxf::handleHatchData( DL_CreationInterface* creationInterface )
|
||||
{
|
||||
case 10:
|
||||
hatchEdge.type = 0;
|
||||
hatchEdge.vertices.push_back( std::vector<double>() );
|
||||
hatchEdge.vertices.emplace_back( );
|
||||
hatchEdge.vertices.back().push_back( toReal( groupValue ) );
|
||||
return true;
|
||||
|
||||
|
@ -397,12 +397,12 @@ void LIB_ARC::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >
|
||||
|
||||
msg = MessageTextFromValue( aUnits, m_Width, true );
|
||||
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
|
||||
aList.emplace_back( _( "Line Width" ), msg, BLUE );
|
||||
|
||||
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
|
||||
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
|
||||
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
|
||||
aList.emplace_back( _( "Bounding Box" ), msg, BROWN );
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user