From b0372883fff3b52b1b5e921a305df3f23094cce9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 11 Jul 2019 15:45:11 +0200 Subject: [PATCH] AK: Remove use of copy_ref(). --- AK/AKString.h | 4 ++-- AK/ByteBuffer.h | 5 +++-- AK/RefPtr.h | 6 ++++-- AK/WeakPtr.h | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/AK/AKString.h b/AK/AKString.h index 39a78cfa362..f99e954b400 100755 --- a/AK/AKString.h +++ b/AK/AKString.h @@ -45,7 +45,7 @@ public: } String(const String& other) - : m_impl(const_cast(other).m_impl.copy_ref()) + : m_impl(const_cast(other).m_impl) { } @@ -173,7 +173,7 @@ public: String& operator=(const String& other) { if (this != &other) - m_impl = const_cast(other).m_impl.copy_ref(); + m_impl = const_cast(other).m_impl; return *this; } diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index 5e4122b73e4..f2cc8d623f4 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -82,7 +82,7 @@ public: ByteBuffer() {} ByteBuffer(std::nullptr_t) {} ByteBuffer(const ByteBuffer& other) - : m_impl(other.m_impl.copy_ref()) + : m_impl(other.m_impl) { } ByteBuffer(ByteBuffer&& other) @@ -97,7 +97,8 @@ public: } ByteBuffer& operator=(const ByteBuffer& other) { - m_impl = other.m_impl.copy_ref(); + if (this != &other) + m_impl = other.m_impl; return *this; } diff --git a/AK/RefPtr.h b/AK/RefPtr.h index bcf04ec328d..2bda6097892 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -64,13 +64,15 @@ public: { } RefPtr(const RefPtr& other) - : m_ptr(const_cast(other).copy_ref().leak_ref()) + : m_ptr(const_cast(other.ptr())) { + ref_if_not_null(m_ptr); } template RefPtr(const RefPtr& other) - : m_ptr(const_cast&>(other).copy_ref().leak_ref()) + : m_ptr(static_cast(const_cast(other.ptr()))) { + ref_if_not_null(m_ptr); } ~RefPtr() { diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index ea60cd16c51..1b8297b356c 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -51,7 +51,7 @@ public: bool operator==(const OwnPtr& other) const { return ptr() == other.ptr(); } private: - WeakPtr(RefPtr>&& link) + WeakPtr(RefPtr> link) : m_link(move(link)) { } @@ -64,7 +64,7 @@ inline WeakPtr Weakable::make_weak_ptr() { if (!m_link) m_link = adopt(*new WeakLink(static_cast(*this))); - return WeakPtr(m_link.copy_ref()); + return WeakPtr(m_link); } template