From bad8ab697b613d6d7b39c442d69ca5f75bd8d737 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 24 Jun 2019 10:23:59 +0200 Subject: [PATCH] NonnullRefPtr: Simplify copy constructors. --- AK/NonnullRefPtr.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index c3c3becff96..acc919b2b6a 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -74,14 +74,16 @@ public: } RETURN_TYPESTATE(unconsumed) NonnullRefPtr(const NonnullRefPtr& other) - : m_ptr(&const_cast(other).copy_ref().leak_ref()) + : m_ptr(const_cast(other.ptr())) { + m_ptr->ref(); } template RETURN_TYPESTATE(unconsumed) NonnullRefPtr(const NonnullRefPtr& other) - : m_ptr(&const_cast&>(other).copy_ref().leak_ref()) + : m_ptr(const_cast(static_cast((other.ptr())))) { + m_ptr->ref(); } ~NonnullRefPtr() {