Some performance enhancements contributed by Oleg Endo.

Fixes: lp:1846438
* https://bugs.launchpad.net/kicad/+bug/1846438
This commit is contained in:
Jeff Young 2019-10-04 19:38:10 +01:00
parent c7c49cee5a
commit 429c7055e9
2 changed files with 14 additions and 7 deletions

View File

@ -339,10 +339,10 @@ bool CN_ANCHOR::IsDangling() const
{ {
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item->Parent() ); ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item->Parent() );
if( zone->HitTestFilledArea( wxPoint( Pos().x, Pos().y ) ) ) if( zone->HitTestFilledArea( (wxPoint) Pos() ) )
connected_count++; connected_count++;
} }
else if( item->Parent()->HitTest( wxPoint( Pos().x, Pos().y ) ) ) else if( item->Parent()->HitTest( (wxPoint) Pos() ) )
connected_count++; connected_count++;
} }

View File

@ -109,7 +109,7 @@ public:
m_cluster = aCluster; m_cluster = aCluster;
} }
inline std::shared_ptr<CN_CLUSTER> GetCluster() const inline const std::shared_ptr<CN_CLUSTER>& GetCluster() const
{ {
return m_cluster; return m_cluster;
} }
@ -159,7 +159,7 @@ typedef std::vector<CN_ANCHOR_PTR> CN_ANCHORS;
class CN_ITEM : public INTRUSIVE_LIST<CN_ITEM> class CN_ITEM : public INTRUSIVE_LIST<CN_ITEM>
{ {
public: public:
using CONNECTED_ITEMS = std::set<CN_ITEM*>; using CONNECTED_ITEMS = std::vector<CN_ITEM*>;
private: private:
BOARD_CONNECTED_ITEM* m_parent; BOARD_CONNECTED_ITEM* m_parent;
@ -201,15 +201,16 @@ public:
m_visited = false; m_visited = false;
m_valid = true; m_valid = true;
m_dirty = true; m_dirty = true;
m_anchors.reserve( 2 ); m_anchors.reserve( std::max( 6, aAnchorCount ) );
m_layers = LAYER_RANGE( 0, PCB_LAYER_ID_COUNT ); m_layers = LAYER_RANGE( 0, PCB_LAYER_ID_COUNT );
m_connected.reserve( 8 );
} }
virtual ~CN_ITEM() {}; virtual ~CN_ITEM() {};
void AddAnchor( const VECTOR2I& aPos ) void AddAnchor( const VECTOR2I& aPos )
{ {
m_anchors.emplace_back( std::make_unique<CN_ANCHOR>( aPos, this ) ); m_anchors.emplace_back( std::make_shared<CN_ANCHOR>( aPos, this ) );
} }
CN_ANCHORS& Anchors() CN_ANCHORS& Anchors()
@ -320,7 +321,13 @@ public:
void Connect( CN_ITEM* b ) void Connect( CN_ITEM* b )
{ {
std::lock_guard<std::mutex> lock( m_listLock ); std::lock_guard<std::mutex> lock( m_listLock );
m_connected.insert( b );
auto i = std::lower_bound( m_connected.begin(), m_connected.end(), b );
if( i != m_connected.end() && *i == b )
return;
m_connected.insert( i, b );
} }
void RemoveInvalidRefs(); void RemoveInvalidRefs();