mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +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:
parent
23d111a459
commit
34922c0cc0
1 changed files with 2 additions and 16 deletions
|
@ -19,22 +19,8 @@ public:
|
||||||
static ErrorOr<CircularBuffer> create_empty(size_t size);
|
static ErrorOr<CircularBuffer> create_empty(size_t size);
|
||||||
static ErrorOr<CircularBuffer> create_initialized(ByteBuffer);
|
static ErrorOr<CircularBuffer> create_initialized(ByteBuffer);
|
||||||
|
|
||||||
CircularBuffer(CircularBuffer&& other)
|
CircularBuffer(CircularBuffer&& other) = default;
|
||||||
{
|
CircularBuffer& operator=(CircularBuffer&& other) = default;
|
||||||
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() = default;
|
~CircularBuffer() = default;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue