diff --git a/pcbnew/router/pns_diff_pair.h b/pcbnew/router/pns_diff_pair.h index a9fb323e92..16527e1664 100644 --- a/pcbnew/router/pns_diff_pair.h +++ b/pcbnew/router/pns_diff_pair.h @@ -261,8 +261,8 @@ public: m_hasVias( false ) { // Initialize some members, to avoid uninitialized variables. - m_net_p = 0; - m_net_n = 0;; + m_net_p = nullptr; + m_net_n = nullptr; m_width = 0; m_gap = 0; m_viaGap = 0; @@ -277,8 +277,8 @@ public: m_gapConstraint = aGap; // Initialize other members, to avoid uninitialized variables. - m_net_p = 0; - m_net_n = 0;; + m_net_p = nullptr; + m_net_n = nullptr; m_width = 0; m_gap = 0; m_viaGap = 0; @@ -295,8 +295,8 @@ public: m_gapConstraint = aGap; // Initialize other members, to avoid uninitialized variables. - m_net_p = 0; - m_net_n = 0;; + m_net_p = nullptr; + m_net_n = nullptr; m_width = 0; m_gap = 0; m_viaGap = 0; @@ -324,6 +324,12 @@ public: m_chamferLimit = 0; } + DIFF_PAIR( const DIFF_PAIR& aOther ) : + LINK_HOLDER( ITEM::DIFF_PAIR_T ) + { + *this = aOther; + } + static inline bool ClassOf( const ITEM* aItem ) { return aItem && ITEM::DIFF_PAIR_T == aItem->Kind(); @@ -335,6 +341,54 @@ public: return nullptr; } + // Copy operator + DIFF_PAIR& operator=( const DIFF_PAIR& aOther ) + { + m_n = aOther.m_n; + m_p = aOther.m_p; + m_line_n = aOther.m_line_n; + m_line_p = aOther.m_line_p; + m_via_n = aOther.m_via_n; + m_via_p = aOther.m_via_p; + + m_hasVias = aOther.m_hasVias; + m_net_n = aOther.m_net_n; + m_net_p = aOther.m_net_p; + m_width = aOther.m_width; + m_gap = aOther.m_gap; + m_viaGap = aOther.m_viaGap; + m_maxUncoupledLength = aOther.m_maxUncoupledLength; + m_chamferLimit = aOther.m_chamferLimit; + m_gapConstraint = aOther.m_gapConstraint; + return *this; + } + + // Move assignment operator + DIFF_PAIR& operator=( DIFF_PAIR&& aOther ) noexcept + { + if (this != &aOther) + { + m_n = std::move( aOther.m_n ); + m_p = std::move( aOther.m_p ); + m_line_n = std::move( aOther.m_line_n ); + m_line_p = std::move( aOther.m_line_p ); + m_via_n = aOther.m_via_n; + m_via_p = aOther.m_via_p; + + m_hasVias = aOther.m_hasVias; + m_net_n = aOther.m_net_n; + m_net_p = aOther.m_net_p; + m_width = aOther.m_width; + m_gap = aOther.m_gap; + m_viaGap = aOther.m_viaGap; + m_maxUncoupledLength = aOther.m_maxUncoupledLength; + m_chamferLimit = aOther.m_chamferLimit; + m_gapConstraint = aOther.m_gapConstraint; + } + + return *this; + } + virtual void ClearLinks() override { m_links.clear(); @@ -342,8 +396,6 @@ public: m_line_n.ClearLinks(); } - static DIFF_PAIR* AssembleDp( LINE *aLine ); - void SetShape( const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN& aN, bool aSwapLanes = false ) { if( aSwapLanes ) diff --git a/pcbnew/router/pns_line.cpp b/pcbnew/router/pns_line.cpp index 4d6c8c4579..1a3535697c 100644 --- a/pcbnew/router/pns_line.cpp +++ b/pcbnew/router/pns_line.cpp @@ -116,6 +116,35 @@ LINE& LINE::operator=( const LINE& aOther ) } +LINE& LINE::operator=( LINE&& aOther ) noexcept +{ + if (this != &aOther) + { + m_parent = aOther.m_parent; + m_sourceItem = aOther.m_sourceItem; + + m_line = std::move( aOther.m_line ); + m_width = aOther.m_width; + m_net = aOther.m_net; + m_movable = aOther.m_movable; + m_layers = aOther.m_layers; + + m_via = aOther.m_via; + + m_marker = aOther.m_marker; + m_rank = aOther.m_rank; + m_routable = aOther.m_routable; + m_owner = aOther.m_owner; + m_snapThreshhold = aOther.m_snapThreshhold; + m_blockingObstacle = aOther.m_blockingObstacle; + + m_links = std::move( aOther.m_links ); + } + + return *this; +} + + LINE* LINE::Clone() const { LINE* l = new LINE( *this ); diff --git a/pcbnew/router/pns_line.h b/pcbnew/router/pns_line.h index c1d8595b4a..4928e0e19c 100644 --- a/pcbnew/router/pns_line.h +++ b/pcbnew/router/pns_line.h @@ -116,8 +116,12 @@ public: /// @copydoc ITEM::Clone() virtual LINE* Clone() const override; + // Copy operator LINE& operator=( const LINE& aOther ); + // Move assignment operator + LINE& operator=( LINE&& aOther ) noexcept; + bool IsLinkedChecked() const { return IsLinked() && LinkCount() == ShapeCount(); diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index c406b8de87..bcfdda382a 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -2148,7 +2148,7 @@ void FIXED_TAIL::AddStage( const VECTOR2I& aStart, int aLayer, bool placingVias, st.pts.push_back(pt); st.commit = aNode; - m_stages.push_back( st ); + m_stages.push_back( std::move( st ) ); } diff --git a/pcbnew/router/pns_line_placer.h b/pcbnew/router/pns_line_placer.h index c62e253314..c479fdc692 100644 --- a/pcbnew/router/pns_line_placer.h +++ b/pcbnew/router/pns_line_placer.h @@ -61,6 +61,35 @@ public: struct STAGE { + STAGE() : + commit( nullptr ) + {} + + STAGE( const STAGE& aOther ) + { + *this = aOther; + } + + // Copy operator + STAGE& operator=( const STAGE& aOther ) + { + commit = aOther.commit; + pts = aOther.pts; + return *this; + } + + // Move assignment operator + STAGE& operator=( STAGE&& aOther ) noexcept + { + if (this != &aOther) + { + commit = aOther.commit; + pts = std::move( aOther.pts ); + } + + return *this; + } + NODE* commit; std::vector pts; }; diff --git a/pcbnew/router/pns_meander.h b/pcbnew/router/pns_meander.h index 52b8c8a0e6..71b04d5edb 100644 --- a/pcbnew/router/pns_meander.h +++ b/pcbnew/router/pns_meander.h @@ -566,6 +566,24 @@ public: */ const MEANDER_SETTINGS& Settings() const; + // Move assignment operator + MEANDERED_LINE& operator=( MEANDERED_LINE&& aOther ) noexcept + { + if (this != &aOther) + { + m_last = aOther.m_last; + + m_placer = aOther.m_placer; + m_meanders = std::move( aOther.m_meanders ); + + m_dual = aOther.m_dual; + m_width = aOther.m_width; + m_baselineOffset = aOther.m_baselineOffset; + } + + return *this; + } + private: VECTOR2I m_last; diff --git a/pcbnew/router/pns_multi_dragger.cpp b/pcbnew/router/pns_multi_dragger.cpp index 9b45d6d5be..2d06bd1f79 100644 --- a/pcbnew/router/pns_multi_dragger.cpp +++ b/pcbnew/router/pns_multi_dragger.cpp @@ -281,7 +281,7 @@ bool clipToOtherLine( NODE* aNode, const LINE& aRef, LINE& aClipped ) constexpr int clipLengthThreshold = 100; - auto dbg = ROUTER::GetInstance()->GetInterface()->GetDebugDecorator(); + //DEBUG_DECORATOR* dbg = ROUTER::GetInstance()->GetInterface()->GetDebugDecorator(); LINE l( aClipped ); SHAPE_LINE_CHAIN tightest; @@ -301,20 +301,25 @@ bool clipToOtherLine( NODE* aNode, const LINE& aRef, LINE& aClipped ) //PNS_DBG( dbg, 3int, pclip, WHITE, 500000, wxT("")); - if( l.Collide( &aRef, aNode, l.Layer(), &ctx ) ) { didClip = true; curL -= step; step /= 2; - } else { - tightest = sl_tmp; - if ( didClip ) + } + else + { + tightest = std::move( sl_tmp ); + + if( didClip ) { curL += step; step /= 2; - } else + } + else + { break; + } } } diff --git a/pcbnew/router/pns_optimizer.cpp b/pcbnew/router/pns_optimizer.cpp index 6af6664e92..dca6efe18e 100644 --- a/pcbnew/router/pns_optimizer.cpp +++ b/pcbnew/router/pns_optimizer.cpp @@ -478,7 +478,7 @@ bool OPTIMIZER::mergeObtuse( LINE* aLine ) SHAPE_LINE_CHAIN current_path( line ); - while( 1 ) + while( true ) { iter++; int n_segs = current_path.SegmentCount(); @@ -489,8 +489,8 @@ bool OPTIMIZER::mergeObtuse( LINE* aLine ) if( step < 2 ) { - line = current_path; - return current_path.SegmentCount() < segs_pre; + line = std::move( current_path ); + return line.SegmentCount() < segs_pre; } bool found_anything = false; @@ -534,15 +534,13 @@ bool OPTIMIZER::mergeObtuse( LINE* aLine ) { if( step <= 2 ) { - line = current_path; + line = std::move( current_path ); return line.SegmentCount() < segs_pre; } step--; } } - - return line.SegmentCount() < segs_pre; } @@ -560,7 +558,7 @@ bool OPTIMIZER::mergeFull( LINE* aLine ) SHAPE_LINE_CHAIN current_path( line ); - while( 1 ) + while( true ) { int n_segs = current_path.SegmentCount(); int max_step = n_segs - 2; diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index 5910cc5729..04e73ce979 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -1094,7 +1094,7 @@ SHOVE::SHOVE_STATUS SHOVE::pushOrShoveVia( VIA* aVia, const VECTOR2I& aForce, in lp.second.ClearLinks(); lp.second.DragCorner( p0_pushed, lp.second.CLine().Find( p0 ) ); lp.second.Line().Simplify2(); - draggedLines.push_back( lp ); + draggedLines.push_back( std::move( lp ) ); } } @@ -2255,7 +2255,7 @@ void SHOVE::AddHeads( VIA_HANDLE aHead, VECTOR2I aNewPos, int aPolicy ) ent.viaNewPos = aNewPos; ent.prevVia = aHead; ent.theVia = aHead; - m_headLines.push_back( ent ); + m_headLines.push_back( std::move( ent ) ); } void removeHead( NODE *aNode, LINE& head ) diff --git a/pcbnew/router/pns_shove.h b/pcbnew/router/pns_shove.h index ee7fa0e872..83c6694a30 100644 --- a/pcbnew/router/pns_shove.h +++ b/pcbnew/router/pns_shove.h @@ -117,7 +117,8 @@ private: { ROOT_LINE_ENTRY( LINE* aLine = nullptr, int aPolicy = SHP_DEFAULT ) : rootLine( aLine ), - policy( aPolicy ) {} + policy( aPolicy ) + {} LINE *rootLine = nullptr; VIA* oldVia = nullptr; @@ -141,6 +142,43 @@ private: policy( aPolicy ) {}; + HEAD_LINE_ENTRY( const HEAD_LINE_ENTRY& aOther ) + { + *this = aOther; + } + + // Copy operator + HEAD_LINE_ENTRY& operator=( const HEAD_LINE_ENTRY& aOther ) noexcept + { + geometryModified = aOther.geometryModified; + prevVia = aOther.prevVia; + theVia = aOther.theVia; + draggedVia = aOther.draggedVia; + viaNewPos = aOther.viaNewPos; + origHead = aOther.origHead; + newHead = aOther.newHead; + policy = aOther.policy; + return *this; + } + + // Move assignment operator + HEAD_LINE_ENTRY& operator=( HEAD_LINE_ENTRY&& aOther ) noexcept + { + if (this != &aOther) + { + geometryModified = aOther.geometryModified; + prevVia = aOther.prevVia; + theVia = aOther.theVia; + draggedVia = aOther.draggedVia; + viaNewPos = aOther.viaNewPos; + origHead = std::move( aOther.origHead ); + newHead = std::move( aOther.newHead ); + policy = aOther.policy; + } + + return *this; + } + bool geometryModified = false; std::optional prevVia; std::optional theVia;