Move assignment operators for some hot-path classes.

This commit is contained in:
Jeff Young 2025-08-04 13:04:35 +01:00
parent 43a9c760b1
commit 724e44d5a0
3 changed files with 61 additions and 0 deletions

View File

@ -91,6 +91,12 @@ public:
MAYBE_VERIFY_UTF8( c_str() );
}
UTF8( const UTF8& o ) :
m_s( o.m_s )
{
MAYBE_VERIFY_UTF8( c_str() );
}
UTF8()
{
}
@ -178,6 +184,23 @@ public:
return *this;
}
UTF8& operator=( const UTF8& aOther )
{
m_s = aOther.m_s;
MAYBE_VERIFY_UTF8( c_str() );
return *this;
}
// Move assignment operator
UTF8& operator=( UTF8&& aOther ) noexcept
{
if (this != &aOther)
m_s = std::move( aOther.m_s );
MAYBE_VERIFY_UTF8( c_str() );
return *this;
}
// a substring of a UTF8 is not necessarily a UTF8 if a multibyte character
// was split, so return std::string not UTF8
std::string substr( size_t pos = 0, size_t len = npos ) const

View File

@ -250,6 +250,26 @@ public:
SHAPE_LINE_CHAIN& operator=( const SHAPE_LINE_CHAIN& ) = default;
// Move assignment operator
SHAPE_LINE_CHAIN& operator=( SHAPE_LINE_CHAIN&& aOther ) noexcept
{
if (this != &aOther)
{
SHAPE_LINE_CHAIN_BASE::operator=( aOther );
m_points = std::move( aOther.m_points );
m_shapes = std::move( aOther.m_shapes );
m_arcs = std::move( aOther.m_arcs );
m_accuracy = aOther.m_accuracy;
m_closed = aOther.m_closed;
m_width = aOther.m_width;
m_bbox = aOther.m_bbox;
}
return *this;
}
SHAPE* Clone() const override;
/**

View File

@ -535,6 +535,24 @@ public:
SHAPE_POLY_SET& operator=( const SHAPE_POLY_SET& aOther );
// Move assignment operator
SHAPE_POLY_SET& operator=( SHAPE_POLY_SET&& aOther ) noexcept
{
if (this != &aOther)
{
SHAPE::operator=( aOther );
m_polys = std::move( aOther.m_polys );
m_triangulatedPolys = std::move( aOther.m_triangulatedPolys );
m_hash = aOther.m_hash;
m_hashValid = aOther.m_hashValid;
m_triangulationValid.store( aOther.m_triangulationValid );
}
return *this;
}
/**
* Build a polygon triangulation, needed to draw a polygon on OpenGL and in some
* other calculations