mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03: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
Notes:
sideshowbarker
2024-07-17 01:42:23 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/34922c0cc0 Pull-request: https://github.com/SerenityOS/serenity/pull/16898 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/awesomekling
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user