1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

AK: Remove use of copy_ref().

This commit is contained in:
Andreas Kling 2019-07-11 15:45:11 +02:00
parent 5254a320d8
commit b0372883ff
4 changed files with 11 additions and 8 deletions

View file

@ -45,7 +45,7 @@ public:
} }
String(const String& other) String(const String& other)
: m_impl(const_cast<String&>(other).m_impl.copy_ref()) : m_impl(const_cast<String&>(other).m_impl)
{ {
} }
@ -173,7 +173,7 @@ public:
String& operator=(const String& other) String& operator=(const String& other)
{ {
if (this != &other) if (this != &other)
m_impl = const_cast<String&>(other).m_impl.copy_ref(); m_impl = const_cast<String&>(other).m_impl;
return *this; return *this;
} }

View file

@ -82,7 +82,7 @@ public:
ByteBuffer() {} ByteBuffer() {}
ByteBuffer(std::nullptr_t) {} ByteBuffer(std::nullptr_t) {}
ByteBuffer(const ByteBuffer& other) ByteBuffer(const ByteBuffer& other)
: m_impl(other.m_impl.copy_ref()) : m_impl(other.m_impl)
{ {
} }
ByteBuffer(ByteBuffer&& other) ByteBuffer(ByteBuffer&& other)
@ -97,7 +97,8 @@ public:
} }
ByteBuffer& operator=(const ByteBuffer& other) ByteBuffer& operator=(const ByteBuffer& other)
{ {
m_impl = other.m_impl.copy_ref(); if (this != &other)
m_impl = other.m_impl;
return *this; return *this;
} }

View file

@ -64,13 +64,15 @@ public:
{ {
} }
RefPtr(const RefPtr& other) RefPtr(const RefPtr& other)
: m_ptr(const_cast<RefPtr&>(other).copy_ref().leak_ref()) : m_ptr(const_cast<T*>(other.ptr()))
{ {
ref_if_not_null(m_ptr);
} }
template<typename U> template<typename U>
RefPtr(const RefPtr<U>& other) RefPtr(const RefPtr<U>& other)
: m_ptr(const_cast<RefPtr<U>&>(other).copy_ref().leak_ref()) : m_ptr(static_cast<T*>(const_cast<U*>(other.ptr())))
{ {
ref_if_not_null(m_ptr);
} }
~RefPtr() ~RefPtr()
{ {

View file

@ -51,7 +51,7 @@ public:
bool operator==(const OwnPtr<T>& other) const { return ptr() == other.ptr(); } bool operator==(const OwnPtr<T>& other) const { return ptr() == other.ptr(); }
private: private:
WeakPtr(RefPtr<WeakLink<T>>&& link) WeakPtr(RefPtr<WeakLink<T>> link)
: m_link(move(link)) : m_link(move(link))
{ {
} }
@ -64,7 +64,7 @@ inline WeakPtr<T> Weakable<T>::make_weak_ptr()
{ {
if (!m_link) if (!m_link)
m_link = adopt(*new WeakLink<T>(static_cast<T&>(*this))); m_link = adopt(*new WeakLink<T>(static_cast<T&>(*this)));
return WeakPtr<T>(m_link.copy_ref()); return WeakPtr<T>(m_link);
} }
template<typename T> template<typename T>