diff --git a/AK/AKString.h b/AK/AKString.h index 39a78cfa36..f99e954b40 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 5e4122b73e..f2cc8d623f 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 bcf04ec328..2bda609789 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 ea60cd16c5..1b8297b356 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