Fill in some move assignment operators.

This commit is contained in:
Jeff Young
2025-09-26 13:32:19 +01:00
parent 730e5dab66
commit 2a0ef9a82d
10 changed files with 198 additions and 25 deletions
+60 -8
View File
@@ -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 )
+29
View File
@@ -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 );
+4
View File
@@ -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();
+1 -1
View File
@@ -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 ) );
}
+29
View File
@@ -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<FIX_POINT> pts;
};
+18
View File
@@ -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;
+11 -6
View File
@@ -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;
}
}
}
+5 -7
View File
@@ -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;
+2 -2
View File
@@ -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 )
+39 -1
View File
@@ -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<VIA_HANDLE> prevVia;
std::optional<VIA_HANDLE> theVia;