Browse Source

Performance optimizations.

pull/18/head
Jeff Young 6 months ago
parent
commit
9750f7690c
  1. 4
      3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp
  2. 2
      common/string_utils.cpp
  3. 2
      eeschema/sch_io/ltspice/ltspice_schematic.cpp
  4. 2
      kicad/project_template.cpp
  5. 22
      libs/kimath/src/geometry/shape_poly_set.cpp
  6. 2
      pcbnew/board.cpp
  7. 2
      pcbnew/connectivity/connectivity_algo.cpp
  8. 16
      pcbnew/connectivity/from_to_cache.cpp
  9. 10
      pcbnew/dialogs/dialog_board_reannotate.cpp
  10. 36
      pcbnew/drc/drc_creepage_utils.cpp
  11. 2
      pcbnew/footprint.cpp
  12. 2
      pcbnew/pcbexpr_evaluator.h
  13. 2
      pcbnew/teardrop/teardrop_utils.cpp

4
3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp

@ -329,7 +329,7 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
m_params.emplace_back( new PARAM_LIST<int>( "render.raytrace_lightElevation",
&m_Render.raytrace_lightElevation,
default_elevation ) );
std::move( default_elevation ) ) );
const std::vector<int> default_azimuth =
{
@ -338,7 +338,7 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
m_params.emplace_back( new PARAM_LIST<int>( "render.raytrace_lightAzimuth",
&m_Render.raytrace_lightAzimuth,
default_azimuth ) );
std::move( default_azimuth ) ) );
m_params.emplace_back( new PARAM<bool>( "render.show_adhesive",
&m_Render.show_adhesive, true ) );

2
common/string_utils.cpp

@ -1342,7 +1342,7 @@ bool ReplaceIllegalFileNameChars( wxString& aName, int aReplaceChar )
}
if( changed )
aName = result;
aName = std::move( result );
return changed;
}

2
eeschema/sch_io/ltspice/ltspice_schematic.cpp

@ -1178,7 +1178,7 @@ std::vector<LTSPICE_SCHEMATIC::LT_ASC> LTSPICE_SCHEMATIC::StructureBuilder()
lineNumber++;
}
ascFiles.push_back( ascFile );
ascFiles.push_back( std::move( ascFile ) );
}
return ascFiles;

2
kicad/project_template.cpp

@ -74,7 +74,7 @@ PROJECT_TEMPLATE::PROJECT_TEMPLATE( const wxString& aPath )
class FILE_TRAVERSER : public wxDirTraverser
{
public:
FILE_TRAVERSER( std::vector<wxFileName>& files, const wxString exclude ) :
FILE_TRAVERSER( std::vector<wxFileName>& files, const wxString& exclude ) :
m_files( files ),
m_exclude( exclude )
{ }

22
libs/kimath/src/geometry/shape_poly_set.cpp

@ -556,9 +556,9 @@ int SHAPE_POLY_SET::AddOutline( const SHAPE_LINE_CHAIN& aOutline )
wxCHECK2_MSG( aOutline.IsClosed(), poly.back().SetClosed( true ),
"Warning: non-closed outline added to SHAPE_POLY_SET" );
m_polys.push_back( poly );
m_polys.push_back( std::move( poly ) );
return m_polys.size() - 1;
return (int) m_polys.size() - 1;
}
@ -567,7 +567,7 @@ int SHAPE_POLY_SET::AddHole( const SHAPE_LINE_CHAIN& aHole, int aOutline )
assert( m_polys.size() );
if( aOutline < 0 )
aOutline += m_polys.size();
aOutline += (int) m_polys.size();
assert( aOutline < (int)m_polys.size() );
@ -577,7 +577,7 @@ int SHAPE_POLY_SET::AddHole( const SHAPE_LINE_CHAIN& aHole, int aOutline )
poly.push_back( aHole );
return poly.size() - 2;
return (int) poly.size() - 2;
}
@ -741,7 +741,7 @@ void SHAPE_POLY_SET::RebuildHolesFromContours()
for( int topParentId : topLevelParents )
{
std::vector<int> path;
process( topParentId, -1, path );
process( topParentId, -1, std::move( path ) );
}
*this = result;
@ -1156,7 +1156,7 @@ void SHAPE_POLY_SET::importPolyPath( const std::unique_ptr<Clipper2Lib::PolyPath
importPolyPath( grandchild, aZValueBuffer, aArcBuffer );
}
m_polys.push_back( paths );
m_polys.emplace_back( std::move( paths ) );
}
}
@ -1197,7 +1197,7 @@ void SHAPE_POLY_SET::importPaths( Clipper2Lib::Paths64& aPath,
}
if( !path.empty() )
m_polys.emplace_back( path );
m_polys.emplace_back( std::move( path ) );
}
@ -1208,7 +1208,9 @@ struct FractureEdge
FractureEdge() = default;
FractureEdge( const VECTOR2I& p1, const VECTOR2I& p2, Index next ) :
m_p1( p1 ), m_p2( p2 ), m_next( next )
m_p1( p1 ),
m_p2( p2 ),
m_next( next )
{
}
@ -1831,7 +1833,7 @@ void SHAPE_POLY_SET::unfractureSingle( SHAPE_POLY_SET::POLYGON& aPoly )
if( outline > 0 )
std::swap( result[0], result[outline] );
aPoly = result;
aPoly = std::move( result );
}
@ -1994,7 +1996,7 @@ bool SHAPE_POLY_SET::Parse( std::stringstream& aStream )
outline.Append( p );
}
paths.push_back( outline );
paths.push_back( std::move( outline ) );
}
m_polys.push_back( paths );

2
pcbnew/board.cpp

@ -1463,7 +1463,7 @@ void BOARD::DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions )
}
}
m_markers = remaining;
m_markers = std::move( remaining );
}

2
pcbnew/connectivity/connectivity_algo.cpp

@ -400,7 +400,7 @@ CN_CONNECTIVITY_ALGO::SearchClusters( CLUSTER_SEARCH_MODE aMode, bool aExcludeZo
}
}
clusters.push_back( cluster );
clusters.push_back( std::move( cluster ) );
}
if( m_progressReporter && m_progressReporter->IsCancelled() )

16
pcbnew/connectivity/from_to_cache.cpp

@ -44,7 +44,7 @@ void FROM_TO_CACHE::buildEndpointList( )
m_ftEndpoints.push_back( ent );
ent.name = footprint->GetReference();
ent.parent = pad;
m_ftEndpoints.push_back( ent );
m_ftEndpoints.push_back( std::move( ent ) );
}
}
}
@ -77,7 +77,7 @@ static PATH_STATUS uniquePathBetweenNodes( CN_ITEM* u, CN_ITEM* v, std::vector<C
Path pInit;
bool pathFound = false;
pInit.push_back( u );
Q.push_back( pInit );
Q.push_back( std::move( pInit ) );
while( Q.size() )
{
@ -100,17 +100,19 @@ static PATH_STATUS uniquePathBetweenNodes( CN_ITEM* u, CN_ITEM* v, std::vector<C
bool vertexVisited = isVertexVisited( ci, path );
for( std::vector<CN_ITEM*>& p : Q )
{
if( isVertexVisited( ci, p ) )
{
vertexVisited = true;
break;
}
}
if( !vertexVisited )
{
Path newpath( path );
newpath.push_back( ci );
Q.push_back( newpath );
Q.push_back( std::move( newpath ) );
}
}
}
@ -133,7 +135,7 @@ int FROM_TO_CACHE::cacheFromToPaths( const wxString& aFrom, const wxString& aTo
p.net = endpoint.parent->GetNetCode();
p.from = endpoint.parent;
p.to = nullptr;
paths.push_back(p);
paths.push_back( std::move( p ) );
}
}
@ -207,12 +209,10 @@ int FROM_TO_CACHE::cacheFromToPaths( const wxString& aFrom, const wxString& aTo
if( result == PS_NO_PATH )
continue;
for( const auto item : upath )
{
for( const CN_ITEM* item : upath )
path.pathItems.insert( item->Parent() );
}
m_ftPaths.push_back(path);
m_ftPaths.push_back( path );
newPaths++;
}

10
pcbnew/dialogs/dialog_board_reannotate.cpp

@ -722,7 +722,7 @@ bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector<REFDES_INFO>& aBad
// Get the type (R, C, etc)
fpData.RefDesType = fpData.RefDesString.substr( 0, firstnum );
for( wxString excluded : m_excludeArray )
for( const wxString& excluded : m_excludeArray )
{
if( excluded == fpData.RefDesType ) // Am I supposed to exclude this type?
{
@ -742,7 +742,7 @@ bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector<REFDES_INFO>& aBad
{ // If only annotating selected c
fpData.Action = EXCLUDE_REFDES; // Assume it isn't selected
for( KIID sel : selected )
for( const KIID& sel : selected )
{
if( fpData.Uuid == sel )
{ // Found in selected footprints
@ -827,19 +827,19 @@ void DIALOG_BOARD_REANNOTATE::BuildUnavailableRefsList()
{
std::vector<REFDES_INFO> excludedFootprints;
for( REFDES_INFO fpData : m_frontFootprints )
for( const REFDES_INFO& fpData : m_frontFootprints )
{
if( fpData.Action == EXCLUDE_REFDES )
excludedFootprints.push_back( fpData );
}
for( REFDES_INFO fpData : m_backFootprints )
for( const REFDES_INFO& fpData : m_backFootprints )
{
if( fpData.Action == EXCLUDE_REFDES )
excludedFootprints.push_back( fpData );
}
for( REFDES_INFO fpData : excludedFootprints )
for( const REFDES_INFO& fpData : excludedFootprints )
{
if( fpData.Action == EXCLUDE_REFDES )
{

36
pcbnew/drc/drc_creepage_utils.cpp

@ -1716,14 +1716,12 @@ std::vector<PATH_CONNECTION> CU_SHAPE_ARC::Paths( const CU_SHAPE_ARC& aS2, doubl
}
}
for( std::vector<PATH_CONNECTION> pcs : { pcs3, pcs4, pcs5, pcs6 } )
for( const std::vector<PATH_CONNECTION>& pcs : { pcs3, pcs4, pcs5, pcs6 } )
{
for( PATH_CONNECTION& pc : pcs )
for( const PATH_CONNECTION& pc : pcs )
{
if( bestPath.weight > pc.weight )
{
bestPath = pc;
}
}
}
@ -1781,13 +1779,15 @@ bool SegmentIntersectsBoard( const VECTOR2I& aP1, const VECTOR2I& aP2,
{
case SHAPE_T::SEGMENT:
{
bool intersects =
segments_intersect( aP1, aP2, d->GetStart(), d->GetEnd(), &intersectionPoints );
bool intersects = segments_intersect( aP1, aP2, d->GetStart(), d->GetEnd(),
&intersectionPoints );
if( intersects && !TestGrooveWidth )
return false;
break;
}
case SHAPE_T::RECTANGLE:
{
VECTOR2I c1 = d->GetStart();
@ -1802,11 +1802,11 @@ bool SegmentIntersectsBoard( const VECTOR2I& aP1, const VECTOR2I& aP2,
intersects |= segments_intersect( aP1, aP2, c4, c1, &intersectionPoints );
if( intersects && !TestGrooveWidth )
{
return false;
}
break;
}
case SHAPE_T::POLY:
{
std::vector<VECTOR2I> points;
@ -1814,28 +1814,29 @@ bool SegmentIntersectsBoard( const VECTOR2I& aP1, const VECTOR2I& aP2,
if( points.size() < 2 )
break;
VECTOR2I prevPoint = points.back();
bool intersects = false;
for( auto p : points )
for( const VECTOR2I& p : points )
{
intersects |= segments_intersect( aP1, aP2, prevPoint, p, &intersectionPoints );
prevPoint = p;
}
if( intersects && !TestGrooveWidth )
{
return false;
}
break;
}
case SHAPE_T::CIRCLE:
{
VECTOR2I center = d->GetCenter();
double radius = d->GetRadius();
bool intersects =
segmentIntersectsCircle( aP1, aP2, center, radius, &intersectionPoints );
bool intersects = segmentIntersectsCircle( aP1, aP2, center, radius, &intersectionPoints );
if( intersects && !TestGrooveWidth )
return false;
@ -1843,7 +1844,6 @@ bool SegmentIntersectsBoard( const VECTOR2I& aP1, const VECTOR2I& aP2,
break;
}
case SHAPE_T::ARC:
{
VECTOR2I center = d->GetCenter();
@ -1852,8 +1852,7 @@ bool SegmentIntersectsBoard( const VECTOR2I& aP1, const VECTOR2I& aP2,
EDA_ANGLE A, B;
d->CalcArcAngles( A, B );
bool intersects =
segmentIntersectsArc( aP1, aP2, center, radius, A, B, &intersectionPoints );
bool intersects = segmentIntersectsArc( aP1, aP2, center, radius, A, B, &intersectionPoints );
if( intersects && !TestGrooveWidth )
return false;
@ -1906,19 +1905,20 @@ bool SegmentIntersectsBoard( const VECTOR2I& aP1, const VECTOR2I& aP2,
for( size_t i = 0; i < intersectionPoints.size(); i += 2 )
{
if( intersectionPoints[i].SquaredDistance( intersectionPoints[i + 1] ) > GVSquared )
{
return false;
}
}
return true;
}
bool CheckPathValidity( VECTOR2I aP1, VECTOR2I aP2, std::vector<BOARD_ITEM*> aBe,
std::vector<const BOARD_ITEM*> aDontTestAgainst )
{
return false;
}
std::vector<PATH_CONNECTION> GetPaths( CREEP_SHAPE* aS1, CREEP_SHAPE* aS2, double aMaxWeight )
{
double maxWeight = aMaxWeight;

2
pcbnew/footprint.cpp

@ -564,7 +564,7 @@ bool FOOTPRINT::Deserialize( const google::protobuf::Any &aContainer )
model.m_Rotation = kiapi::common::UnpackVector3D( modelMsg.rotation() );
model.m_Offset = kiapi::common::UnpackVector3D( modelMsg.offset() );
Models().push_back( model );
Models().push_back( std::move( model ) );
}
else
{

2
pcbnew/pcbexpr_evaluator.h

@ -250,7 +250,7 @@ public:
void SetErrorCallback( std::function<void( const wxString& aMessage, int aOffset )> aCallback )
{
m_compiler.SetErrorCallback( aCallback );
m_compiler.SetErrorCallback( std::move( aCallback ) );
}
bool IsErrorPending() const { return m_errorStatus.pendingError; }

2
pcbnew/teardrop/teardrop_utils.cpp

@ -745,7 +745,7 @@ bool TEARDROP_MANAGER::computeTeardropPolygon( const TEARDROP_PARAMETERS& aParam
if( !aParams.m_CurvedEdges )
{
aCorners = pts;
aCorners = std::move( pts );
return true;
}

Loading…
Cancel
Save