Performance.

(cherry picked from commit 2793bb1d68)
This commit is contained in:
Jeff Young 2023-04-16 14:55:18 +01:00
parent f3db64af05
commit 1d37d3fdf7
1 changed files with 10 additions and 10 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application.
* *
* Copyright (C) 2013-2017 CERN * Copyright (C) 2013-2017 CERN
* Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
@ -166,7 +166,7 @@ public:
m_allNodes.clear(); m_allNodes.clear();
} }
void AddNode( std::shared_ptr<CN_ANCHOR> aNode ) void AddNode( const std::shared_ptr<CN_ANCHOR>& aNode )
{ {
m_allNodes.insert( aNode ); m_allNodes.insert( aNode );
} }
@ -333,7 +333,7 @@ void RN_NET::OptimizeRNEdges()
auto optimizeZoneAnchor = auto optimizeZoneAnchor =
[&]( const VECTOR2I& aPos, const LSET& aLayerSet, [&]( const VECTOR2I& aPos, const LSET& aLayerSet,
const std::shared_ptr<const CN_ANCHOR>& aAnchor, const std::shared_ptr<const CN_ANCHOR>& aAnchor,
std::function<void( std::shared_ptr<const CN_ANCHOR> )> setOptimizedTo ) const std::function<void( std::shared_ptr<const CN_ANCHOR> )>& setOptimizedTo )
{ {
SEG::ecoord closest_dist_sq = ( aAnchor->Pos() - aPos ).SquaredEuclideanNorm(); SEG::ecoord closest_dist_sq = ( aAnchor->Pos() - aPos ).SquaredEuclideanNorm();
VECTOR2I closest_pt; VECTOR2I closest_pt;
@ -347,7 +347,7 @@ void RN_NET::OptimizeRNEdges()
{ {
const std::vector<VECTOR2I>& pts = zoneLayer->GetOutline().CPoints(); const std::vector<VECTOR2I>& pts = zoneLayer->GetOutline().CPoints();
for( VECTOR2I pt : pts ) for( const VECTOR2I& pt : pts )
{ {
SEG::ecoord dist_sq = ( pt - aPos ).SquaredEuclideanNorm(); SEG::ecoord dist_sq = ( pt - aPos ).SquaredEuclideanNorm();
@ -368,8 +368,8 @@ void RN_NET::OptimizeRNEdges()
auto optimizeZoneToZoneAnchors = auto optimizeZoneToZoneAnchors =
[&]( const std::shared_ptr<const CN_ANCHOR>& a, [&]( const std::shared_ptr<const CN_ANCHOR>& a,
const std::shared_ptr<const CN_ANCHOR>& b, const std::shared_ptr<const CN_ANCHOR>& b,
std::function<void(const std::shared_ptr<const CN_ANCHOR>&)> setOptimizedATo, const std::function<void(const std::shared_ptr<const CN_ANCHOR>&)>& setOptimizedATo,
std::function<void(const std::shared_ptr<const CN_ANCHOR>&)> setOptimizedBTo ) const std::function<void(const std::shared_ptr<const CN_ANCHOR>&)>& setOptimizedBTo )
{ {
for( CN_ITEM* itemA : a->Item()->ConnectedItems() ) for( CN_ITEM* itemA : a->Item()->ConnectedItems() )
{ {
@ -415,7 +415,7 @@ void RN_NET::OptimizeRNEdges()
if( source->ConnectedItemsCount() == 0 ) if( source->ConnectedItemsCount() == 0 )
{ {
optimizeZoneAnchor( source->Pos(), source->Parent()->GetLayerSet(), target, optimizeZoneAnchor( source->Pos(), source->Parent()->GetLayerSet(), target,
[&]( std::shared_ptr<const CN_ANCHOR> optimized ) [&]( const std::shared_ptr<const CN_ANCHOR>& optimized )
{ {
edge.SetTargetNode( optimized ); edge.SetTargetNode( optimized );
} ); } );
@ -423,7 +423,7 @@ void RN_NET::OptimizeRNEdges()
else if( target->ConnectedItemsCount() == 0 ) else if( target->ConnectedItemsCount() == 0 )
{ {
optimizeZoneAnchor( target->Pos(), target->Parent()->GetLayerSet(), source, optimizeZoneAnchor( target->Pos(), target->Parent()->GetLayerSet(), source,
[&]( std::shared_ptr<const CN_ANCHOR> optimized ) [&]( const std::shared_ptr<const CN_ANCHOR>& optimized )
{ {
edge.SetSourceNode( optimized ); edge.SetSourceNode( optimized );
} ); } );
@ -431,11 +431,11 @@ void RN_NET::OptimizeRNEdges()
else else
{ {
optimizeZoneToZoneAnchors( source, target, optimizeZoneToZoneAnchors( source, target,
[&]( std::shared_ptr<const CN_ANCHOR> optimized ) [&]( const std::shared_ptr<const CN_ANCHOR>& optimized )
{ {
edge.SetSourceNode( optimized ); edge.SetSourceNode( optimized );
}, },
[&]( std::shared_ptr<const CN_ANCHOR> optimized ) [&]( const std::shared_ptr<const CN_ANCHOR>& optimized )
{ {
edge.SetTargetNode( optimized ); edge.SetTargetNode( optimized );
} ); } );