1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:17:35 +00:00

AK: Default move operators for CircularBuffer

The previously defined operator was swap-based. With the defaulted
implementation, both integers are now copied, but it doesn't matter as
only the `ByteBuffer` allocates memory (i.e. non-null integers values
won't affect the destruction).
This commit is contained in:
Lucas CHOLLET 2023-01-07 16:58:11 -05:00 committed by Andrew Kaster
parent 23d111a459
commit 34922c0cc0

View file

@ -19,22 +19,8 @@ public:
static ErrorOr<CircularBuffer> create_empty(size_t size);
static ErrorOr<CircularBuffer> create_initialized(ByteBuffer);
CircularBuffer(CircularBuffer&& other)
{
operator=(move(other));
}
CircularBuffer& operator=(CircularBuffer&& other)
{
if (&other == this)
return *this;
swap(m_buffer, other.m_buffer);
swap(m_reading_head, other.m_reading_head);
swap(m_used_space, other.m_used_space);
return *this;
}
CircularBuffer(CircularBuffer&& other) = default;
CircularBuffer& operator=(CircularBuffer&& other) = default;
~CircularBuffer() = default;