diff --git a/pcbnew/connectivity/connectivity_items.cpp b/pcbnew/connectivity/connectivity_items.cpp index e6af071a77..0f4e5e90a3 100644 --- a/pcbnew/connectivity/connectivity_items.cpp +++ b/pcbnew/connectivity/connectivity_items.cpp @@ -339,10 +339,10 @@ bool CN_ANCHOR::IsDangling() const { ZONE_CONTAINER* zone = static_cast( item->Parent() ); - if( zone->HitTestFilledArea( wxPoint( Pos().x, Pos().y ) ) ) + if( zone->HitTestFilledArea( (wxPoint) Pos() ) ) connected_count++; } - else if( item->Parent()->HitTest( wxPoint( Pos().x, Pos().y ) ) ) + else if( item->Parent()->HitTest( (wxPoint) Pos() ) ) connected_count++; } diff --git a/pcbnew/connectivity/connectivity_items.h b/pcbnew/connectivity/connectivity_items.h index 3e6ca7e9af..3bc1d1134a 100644 --- a/pcbnew/connectivity/connectivity_items.h +++ b/pcbnew/connectivity/connectivity_items.h @@ -109,7 +109,7 @@ public: m_cluster = aCluster; } - inline std::shared_ptr GetCluster() const + inline const std::shared_ptr& GetCluster() const { return m_cluster; } @@ -159,7 +159,7 @@ typedef std::vector CN_ANCHORS; class CN_ITEM : public INTRUSIVE_LIST { public: - using CONNECTED_ITEMS = std::set; + using CONNECTED_ITEMS = std::vector; private: BOARD_CONNECTED_ITEM* m_parent; @@ -201,15 +201,16 @@ public: m_visited = false; m_valid = 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_connected.reserve( 8 ); } virtual ~CN_ITEM() {}; void AddAnchor( const VECTOR2I& aPos ) { - m_anchors.emplace_back( std::make_unique( aPos, this ) ); + m_anchors.emplace_back( std::make_shared( aPos, this ) ); } CN_ANCHORS& Anchors() @@ -320,7 +321,13 @@ public: void Connect( CN_ITEM* b ) { std::lock_guard 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();