From 34922c0cc0843d61bb31c018e31883d135030d30 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Sat, 7 Jan 2023 16:58:11 -0500 Subject: [PATCH] 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). --- AK/CircularBuffer.h | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/AK/CircularBuffer.h b/AK/CircularBuffer.h index 08452d4606d..56763601c48 100644 --- a/AK/CircularBuffer.h +++ b/AK/CircularBuffer.h @@ -19,22 +19,8 @@ public: static ErrorOr create_empty(size_t size); static ErrorOr 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;